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

World: r3wp

[Parse] Discussion of PARSE dialect

Steeve
13-Apr-2010
[4900]
especially within R3
Ladislav
13-Apr-2010
[4901]
Your statement cannot be verified, since you did not specify,what 
you mean by "short strings"
Steeve
13-Apr-2010
[4902]
It's simple to understand, it's faster until it's not anymore, depending 
the use cases, do your own tests
Ladislav
13-Apr-2010
[4903]
Yes, "it's faster than anything else, until it's not" is a perfect 
statement, and you got my agreement :-p
Steeve
13-Apr-2010
[4904]
:)
Henrik
13-Apr-2010
[4905]
a short string is one that is not long. :-)
Maxim
13-Apr-2010
[4906]
ladislav, Remark changes the input on the fly to implement function 
html unfolding, and using that improved speed by 50 times, when compared 
with traditional series manipulations.

so yes its seriously usable   ;-P
Ladislav
13-Apr-2010
[4907]
Now, I can make a bold statement: for any method distinct from the 
one using PARSE and CHANGE/PART combo holds, that it is faster than 
the above method, until it's not :-p
Maxim
13-Apr-2010
[4908]
its not a single change/part which is the issue, its managing the 
stack, allocating all those blocks over and over... the sheer speed 
of the parse loop, blows away all the other looped/recursive algorythms 
in my usage so far.
Ladislav
13-Apr-2010
[4909]
Nevertheless, I pointed him to http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Parse#Modifying_the_input_series
BudzinskiC
14-Apr-2010
[4910]
And here I thought yesterday, wow I finally understood Parse and 
gosh it's awesome. And now I read change/part, which I used, is not 
the way to do things unless it is. I am confused! Generally, but 
also now specifically.
Pekr
15-Apr-2010
[4911x2]
I think change/part is as fast as Rebol's change/part native, and 
hence usable, unless Ladislav proves such pov being somehow fundamentally 
wrong :-)
my take on "speed" is as follows - ppl sometimes object, that you 
use "interpreter". And my answer is - why should I care? The thing 
is either fast enough for me, or it is not fast enough for me. If 
you will try to edit video using REBOL level pixel manipulation, 
you surely will not be happy. But - if your app behaves real-time 
or generally time results are acceptable for you - why to worry at 
all?
Ladislav
15-Apr-2010
[4913]
Unless Ladislav proves...

 - I did too many times to not feel repeating myself. Read the above 
 reference, please.
Gregg
15-Apr-2010
[4914]
Petr, it may be more than fast enough for small cases, or where you 
don't need maximum performance (which is most of the time). The inefficiency 
comes from REBOL having to move things around when you insert things 
into a series (list! being a possible exception).
Tomc
15-Apr-2010
[4915]
try this way, with one replace  change may be more efficent , with 
2 replaces bith would need to be in the sccond half of the file , 
with three in the last third ,with 4 the last quarter ...so although 
there may exist pathological cases where it is more efficent it is 
best not to cater to them.  there  may also be an argument  for not 
allocating twice as much memory but iby the time your file is that 
large you are already running into problems (in r2 at least)
Ladislav
16-Apr-2010
[4916x4]
I updated the above mentioned Rebol wikibook section - the speed 
discussion subsection added. So, read, it, please (the latest, i.e. 
yet unsighted version!) and see also the CureCode ticket #1570, which 
is related to this issue.
the unsighted version of the article can be found here: http://en.wikibooks.org/w/index.php?title=REBOL_Programming/Language_Features/Parse&stable=0
Please, if somebody finds a good refinement name, let us know.
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)