r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Parse] Discussion of PARSE dialect

Ladislav
16-Apr-2010
[4919]
BTW, re #1570 - I would like to know, what BrianH thinks about the 
necessity to keep the backward compatibility in this case?
ChristianE
16-Apr-2010
[4920x7]
Not being a native speaker I think you "change somthing in something", 
so that gives >> CHANGE/TO "ABC" "123" == 123
(sorry, I've hit <RETURN> too early)
The above should've read 

>> head change/to "abc" "123" 2
== "12c"
>> head change/part/to "abc" "123" 1 2
== "12bc"
But it doesn't communicate very well the idea of changing to only 
a part of the second argument.
Probably better:
>> head change/take "abc" "123" 2
== "12c"
>> head change/part/take "abc" "123" 1 2
== "12bc"
Of course that has other semantics than

>> head change/part "abc" take/part "123" 2 1
== "12bc"

and may lead to new confusion.
Ladislav
16-Apr-2010
[4927]
thanks, your suggestions look sensible, although I am not sure about 
the /take one
Gabriele
17-Apr-2010
[4928]
i think, it might make more sense to actually implement the often 
talked about series-range! type. Or, have copy-on-write semantics 
for the results of COPY. (the latter would also help multithreading 
IMHO)
Maxim
17-Apr-2010
[4929x2]
/take is a new very usefull function in R3, it's a good idea to use 
it as a refinement to... IMHO
Gab  YESSS!!!


it would also be nice if we could actually just set a soft-range 
to ANY series, removing the need for a specific datatype.
Ladislav
17-Apr-2010
[4931]
Re the series-range! type: did Carl already say he would like to 
have it?
Steeve
17-Apr-2010
[4932x2]
No
Ranges only interest those who  need highly optimized scripts (avoiding 
any memory overhead)
Ladislav
17-Apr-2010
[4934]
In that case, the CHANGE refinement may be the only viable way for 
Carl
Steeve
17-Apr-2010
[4935]
there are several implementation choices in Rebol where we can say: 
Carl does not bother with the memory issue
Maxim
17-Apr-2010
[4936]
and extra speed consideration of having to allocate/copy/destroy 
a series
BrianH
17-Apr-2010
[4937]
I like your #1570 proposal, Ladislav, but not the name. Perhaps /span 
might be better, or /range.
Steeve
17-Apr-2010
[4938x2]
/length
it's true, 'change/part does not behave correctly by default.

insert/part et append/part do the right thing we want now for change
ChristianE
17-Apr-2010
[4940]
That's said too much; I think it's more that CHANGE/PART behaves 
as advertised and the /PART refinement just happens to have a different 
meaning for INSERT or APPEND. 

Neither one of /WITH, /TO, /SPAN and /RANGE communicate very well 
that they refer to the second argument though, and /TAKE has the 
drawback of suggesting that it's taking away from the second argument 
like TAKE instead of leaving the second argument untouched. 

CHANGE/FROM, however, seems to work:

>> head change/from #abcdef #123456 3
== #123def
>> head change/part/from #abcdef #12345 1 3
== #123bcdef 


All that under the assumption that for compatibility, /PART in it's 
current meaning will stay as it is.
BrianH
17-Apr-2010
[4941]
It's funny, I always thought INSERT/part was the weird one, and CHANGE/part 
the normal one. Didn't stop me from adding /part to APPEND though, 
in the INSERT style.
Maxim
17-Apr-2010
[4942x2]
I agree with Christian, except that /from doesn't convay the proper 
meaning... another refinement name might be better...

something like 

change/part/only to from  3 4
change/part/amount to from  3 4

?
except that /only is already used... but I'm just suggesting in the 
lexical sense... something closer to the meaning of the refinement.
BrianH
17-Apr-2010
[4944]
That's why I suggested /span or /range :)
Steeve
17-Apr-2010
[4945x2]
i suggest  /?
it's short
Maxim
17-Apr-2010
[4947]
/?  !?!!??!! 

and meaningless  ;-)
Steeve
17-Apr-2010
[4948]
meaningall
Tomc
18-Apr-2010
[4949]
change/interval ?  (spelled corectly if necessary)
Gregg
19-Apr-2010
[4950]
Comment added: http://curecode.org/rebol3/ticket.rsp?id=1570&cursor=5#comments
Steeve
19-Apr-2010
[4951x3]
Gregg, I used to use append/part to avoid the memory overhead of 
copy/part in many case.
Instead of doing like in the Ladislav's example. 
>> change/part something copy/part something-else range part.
I used  to do.

>> change/part something append/part clear #{} something-else range 
part.
It's not faster, but saves memory.


So, I don't know if it's a good idea to discard this use case from 
append and insert.
Esp in R3
(It saves memory, if the same code is called many times, indeed)
Ladislav
19-Apr-2010
[4954]
Re "it saves memory" - it is not expected to save memory (the GC 
should handle such code "smoothly")
Steeve
19-Apr-2010
[4955x2]
Sometimes, I can't let the GC acts by himself because it's too late 
and tens of MB would be allocated for nothing.
But I agree it's rare cases, with intensive computations. Rare, but 
it exists.
Ladislav
19-Apr-2010
[4957x2]
It does not matter that it is rare: if you can find any unexpected 
of the GC, you should put it to CureCode as a major bug
unexpected behaviour of the GC
Steeve
19-Apr-2010
[4959]
It's not a bug to my mind, the GC never acted smoothly.
Ladislav
19-Apr-2010
[4960x2]
maybe I just misunderstood, then. If it is not a bug, then you are 
actually saying, that the GC collects everything as expected? If 
that is the case, then why the trouble to "save memory"?
(I just tested, and your example is much slower than the code allocating 
and GC-ing the new string)
Steeve
19-Apr-2010
[4962]
Yeah it's true, it's slower.

But if your app contains many loops with many copy/part at different 
locations, the memory may grow insanly before the recycle.
I saw that in many graphic apps with Rebol.
Ladislav
19-Apr-2010
[4963]
I saw that in many graphic app with Rebol
 - are you sure it was "before the recycle"?
BrianH
19-Apr-2010
[4964x2]
Sometimes you don't want to put too much pressure on the GC, and 
sometimes you don't want to increase the total size of the pool too 
much, because that pool doesn't always get returned to the OS very 
quickly or at all. This is the motivation for additions like the 
/into option.
We'll see how much optimizations like that need to be undone once 
we have to adjust for task safety :(
Maxim
19-Apr-2010
[4966x2]
the GC doesn't return the pool... only image data is ever returned 
AFAIK.
and the GC doesn't kick in too quick or it would be really slow  
(just try recycle/torture to see ;-)


so when you're doing serious work it REALLY grows... although it 
stabilizes


for example although stats often show 10MB... my OS tells me that 
its actually using 24 MB.  that will never shrink back down.
florin
24-May-2010
[4968]
Is there a place for the newbie questions on parsing?