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

World: r3wp

[Core] Discuss core issues

Maxim
19-Sep-2010
[18233]
statement: skip post -2
change find statement 'fixed 'changed

?
Ladislav
19-Sep-2010
[18234x5]
>> forall (in a 'b) [print a/b/1]
1
2
3
4
5

Looks more than sufficient for me.
The above is R3, though
The evaluation of these "partially evaluated arguments" has changed 
this way
Nevertheless, I do not like the header of the FORALL function, since 
the WORD argument is actually used to supply two values to the function, 
which is not a KISS strategy
(if this "two in one" method were that good, why it is not used by 
FOREACH, etc.?)
Maxim
19-Sep-2010
[18239]
cause that's how they differ?
Ladislav
19-Sep-2010
[18240x2]
Cetera censeo, the "two in one" argument passing method is improper, 
and should not be used
#1653
Maxim
19-Sep-2010
[18242x3]
would we be just using 

forall word word [print word/1] 

all the time ?
woudn't
<arghh>    wouldn't
Ladislav
19-Sep-2010
[18245x3]
all the time
?
isn't it more frequent, that you actually do:

my-word: [1 2 3]
forall my-word [do something...]

?

That should properly look this way:

forall my-word [1 2 3] [do something...]
Not using FORALL, I actually do not mind, I just wanted to point 
out what is wrong about it
Henrik
19-Sep-2010
[18248]
this is one of the reasons I don't use FORALL very often, but resort 
to repeat i length? <something>
Maxim
19-Sep-2010
[18249]
when I have used forall (and its really rare, cause until is much 
better, usually) I never use litteral data directly, its always some 
data which is already setup elsewhere.
Ladislav
19-Sep-2010
[18250x5]
I am pretty sure, that *if* FORALL was defined properly from the 
start, everybody would perceive a change to the "two in one argument 
passing method" inappropriate. But, since it is a backward compatibility 
issue, you do not see what is wrong about it. Nevertheless: the WORD 
argument is an independent word, which is used to "define" a local 
in the BODY argument, that is why it actually does not make sense 
to use it as a "series container" on entry
(where it is "nonlocal")
To make it absurd, even REPEAT could be modified to use the "two 
in one argument passing method". Would you find it proper?
...and if not, why?
...and I don't think, that an argument "because that is how REPEAT 
differs from FORALL" makes any sense as an argument
Maxim
19-Sep-2010
[18255x2]
well repeat already uses 2 arguments.
ah sorry... read your statement the wrong way.
Ladislav
19-Sep-2010
[18257x3]
In my opinion, different functions are defined not because we like 
to have different functions, but because they do different things 
for us
Assuming (hypothetically), that FORALL did not use the "two in one" 
method, the Graham's example would look as follows:

forall b a/b [print a/b/1]


, which is preferable, since it clearly suggests, that the word 'b 
in the BODY is actually not the same word as in a 'b
Aha, it seems, that I noticed one more strangeness in this. Why actually 
the expression:

forall (in a 'b) [print a/b/1]

prints what it does in R3?
Graham
19-Sep-2010
[18260]
the reason I use 'forall is so I can remove elements of a series 
as I traverse it.

so

forall series [ if series/1 = something [ remove series ]]


which 'foreach doesn't allow because you don't have a reference to 
where you are in the series
Maxim
19-Sep-2010
[18261x3]
use remove-each its MUCH faster.
using your example it becoms.

remove-each [if series/1 = something]
actually... its:
remove-each [series/1 = something]
Henrik
19-Sep-2010
[18264]
remove-each is indeed much faster and it's a native.
Maxim
19-Sep-2010
[18265]
argh... I'm reallly tire.
Graham
19-Sep-2010
[18266]
Only because Carl made it native!
Maxim
19-Sep-2010
[18267x2]
remove-each item series [item = something]
not just because its native... its in the way it actually manages 
the removal... it only re-creates the series once, when its done.


using other methods, you are tampering with the series at each change, 
and it has to copy the series over and over.
Graham
19-Sep-2010
[18269x2]
remove-each mistake maxs-mistakes [ true ] ?
Is that the syntax?  :)
Maxim
19-Sep-2010
[18271]
yep
Steeve
19-Sep-2010
[18272]
Maxim about remove-each, what do you mean by: 
- "it only re-creates the series once, when its done".
Maxim
19-Sep-2010
[18273]
what I have been explained is that it makes a new series and only 
copies when remove is false.  then replaces the pointer within the 
series to the new one.
Ladislav
19-Sep-2010
[18274x2]
Steeve, removal of one object from a block is an O(n) operation, 
where n is the length of the series. That would make a naive implementation 
O(n ** 2), while REMOVE-EACH is just O(n)
...but, actually, no re-creation of series happens anyway
Maxim
19-Sep-2010
[18276x3]
ah yes.. true.. it just copies over itself.
Ladislav, one question I've always wondered and I'm sure you know.
does CLEAR only set the soft size of a series or does it actually 
truncate the internal buffer of a series?
Ladislav
19-Sep-2010
[18279x3]
the former
CLEAR is just O(1)
although,maybe, that in some cases, the GC is able to reassign a 
smaller part of memory to the series, but I doubt it
Steeve
19-Sep-2010
[18282]
Are you sure about that ?
I don't tink remove-each create any temporary buffer.

when I compare the footprint of foreach and remove-each, they are 
the same

(which means nothing, because i don't see why foreach need to create 
so much temporary blocks)