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

World: r3wp

[Core] Discuss core issues

BrianH
22-Jul-2010
[17619]
There is a CureCode ticket requesting that documentation, though 
it is syntax documentation, not datatype.
Maxim
22-Jul-2010
[17620]
yeah, but my associative mind needs to know syntax related information 
based on a datatype, not the other way round  ;-)
BrianH
22-Jul-2010
[17621]
Syntax precedence rules affect more than one datatype by their nature, 
so it should be better for the documentation of the affected datatypes 
to link to the syntax documentation.
Maxim
22-Jul-2010
[17622]
yep... that's what I meant by association  :-D
BrianH
22-Jul-2010
[17623]
If you read what I've been writing today, you'd understand why I 
am paying so much attention to organization of information :)
Graham
23-Jul-2010
[17624]
foreach allows you to step through a single series one at a time. 
 So, how would you step thru more than one series at a time?

a: [ n elements ]
b: [ n elements ]

foreach [ ofa ofb ] reduce [ a b ] [

] 

?
Andreas
23-Jul-2010
[17625x3]
foreach [ofa ofb] join a b [...]
Aehem, nevermind.
use amartin's interweave or gabriele's nforeach
Graham
23-Jul-2010
[17628]
nforeach?? where is this?
Andreas
23-Jul-2010
[17629]
http://www.rebol.it/giesse/utility.r
Graham
23-Jul-2010
[17630x2]
ahh... ok
I also found the relevant mailing list thread
Andreas
23-Jul-2010
[17632]
http://www.mail-archive.com/[rebol-list-:-rebol-:-com]/msg18660.html
Graham
24-Jul-2010
[17633]
Anyreason why this can't be the default behaviour of 'foreach?
Gabriele
24-Jul-2010
[17634]
the one here might be newer (i don't remember and i didn't check 
:P): http://www.colellachiara.com/soft/libs/utility.r
Graham
24-Jul-2010
[17635]
they're both copyright 2003 and one is dated 2004, and the other 
more documented version is dated 2005  !
Gregg
24-Jul-2010
[17636]
The most common case is iterating over a single block, so the current 
behavior makes sense. And while breaking compatibility is sometimes 
helpful in the long run, I hate to think how much code would break 
by changing FOREACH now. FOR, on the other hand, is not widely used 
IIRC, and I've said before I thought it would benefit from being 
a dialected func. Still, we can make our own under a new name and 
then campaign for it.
Graham
24-Jul-2010
[17637x2]
I guess my suggestion is that the current behaviour is for a single 
block, but it should be able to generalise *without* creating a new 
function.
In the same way 'for does ... where there is a skip counter from 
1 .. n
Gabriele
25-Jul-2010
[17639]
graham, i think you underestimate how hard it is to generalize FOREACH. 
:) the only thing i can think of is adding a /multi refinement or 
something like that, but then the way you pass arguments is not optimal.
Graham
25-Jul-2010
[17640]
But it's not impossible right?  :)
Ladislav
25-Jul-2010
[17641]
Why are you asking? You should rather provide a spec enhancement 
of Foreach, if you think it is possible
Graham
25-Jul-2010
[17642x2]
foreach opt [ integer! ]  [ word! block! ] [ block! ]  [ action block 
]


if the optional integer is missing, then assume it's just the one 
block of data you are working with
Otherwise the integer specifies how many data blocks
we could have that for 'for as well ... if the step integer is missing, 
assume one.
Ladislav
25-Jul-2010
[17644]
aha, so you are suggesting a completely incompatible function spec
Graham
25-Jul-2010
[17645x2]
not at all ...
completely backwards compatible ..
Ladislav
25-Jul-2010
[17647]
aha, it is compatible, since your proposed spec is variadic. OK, 
then it is a different problem: you are out of luck with variadic 
functions, not to mention that it is ugly (at least I do not like 
it)
Graham
25-Jul-2010
[17648x3]
in so much as I have to tell the interpreter how many parameters 
... yes
otherwise you have to use something which is different syntax
Anyway, I can't see that' it's any different from skip ... or other 
such
Ladislav
25-Jul-2010
[17651]
The main problem is, that except for DO we do not have (nor it is 
planned) any variadic function in R3
Graham
25-Jul-2010
[17652]
That's not a problem .. just different
Ladislav
25-Jul-2010
[17653x2]
Not a problem? For me it is a crucial problem.
Notice, that even MAKE was made strictly binary (i.e. not variadic 
as in R2) in R3
Graham
25-Jul-2010
[17655x3]
Ok, instead of usig an integer ..

if the first parameter of foreach is a block containing blocks, then 
consider it multiple data blocks
And now we always only have three parameters for foreach
Again that's backwards compatible
Steeve
25-Jul-2010
[17658x2]
Graham, why don't you promote a new function instead ?
just find a good name
Ladislav
25-Jul-2010
[17660]
Thinking about it, it occurs to me might be, if we introduced a | 
keyword into the WORD "dialect" of Foreach as follows:

>> foreach [a b] [[1 2 3] [4 5 6]] [print [mold a mold b]]
[1 2 3] [4 5 6]

, while

foreach [a | b] [[1 2 3] [4 5 6]]
could print

1 4
2 5
3 6
Steeve
25-Jul-2010
[17661x4]
Foreach is so widely used, that no one want it be slowed because 
of some polymorfism behavior.
In resume, your proposal will never be accepted
*polymorphism
Ladislav, I like that
there could be some other operators.
>> foreach [a & b] [[1 2 3] [4 5 6]]

1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
Ladislav
25-Jul-2010
[17665x2]
Well, the dialect would certainly add some polymorphism, as it looks.
Neverthless, the meaning of "combined operators" like [a | b & c] 
may become unclear quickly
BrianH
25-Jul-2010
[17667]
Especially when combined with the new treatment of setwords.
Graham
25-Jul-2010
[17668]
Steeve, Gab already has nforeach .. .I was just looking to reduce 
the number of functions exposed