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

World: r3wp

[!REBOL3-OLD1]

JaimeVargas
20-Dec-2006
[1746]
Rebol functions can't accept a variable number of arguments with 
the exception of refinements. So the issue is becomes important. 
APPLY is kind of incompatible to the principle that * every  function 
has a fixed number of arguments*.
Izkata
20-Dec-2006
[1747]
They can if you take advantage of the unset! datatype...  But it's 
not pretty and more confusing than it's worth
Henrik
20-Dec-2006
[1748]
I just think it would be more straight forward with natives for performing 
arithmetics on blocks. It's more predictable.
Maxim
20-Dec-2006
[1749]
predictable?
Henrik
20-Dec-2006
[1750]
apply :* [] ;== 1 isn't predictable within REBOL terms, I think
JaimeVargas
20-Dec-2006
[1751x2]
APPLY just means run this function with the block content as args. 
So:


APPLY :+ [1 2 3 4]  is equivalent to DO [+ 1 2 3 4]  ;; using scheme 
semantics
If we stick with this definition an no varargs for functions then 
APPLY :+ [1 2 3 4] is impossible it actually should throw an error 
because the native '+ requires two arguments.
Maxim
20-Dec-2006
[1753]
yes Jaime that is how I see it in REBOL too... so in rebol the last 
two args would be ignored if we use the current understanding
JaimeVargas
20-Dec-2006
[1754]
In which case APPLY with math ops is kind of lame compared to scheme.
Maxim
20-Dec-2006
[1755x2]
how does scheme understand to continue grabbing values?  because 
its not hitting an action?
or because it servers args within an argument () ?
JaimeVargas
20-Dec-2006
[1757x3]
I APPLY was simply implemented as the DO translation; you will get 
tons of side effects. Because,


APPLY :+ [1 2 3 4] implented as DO [+ 1 2 3 4] ;== 4 (NOT 10 wich 
is the expected result).
Because in Scheme you can have function with variable number of arguments 
thanks to the parenthetical notation. (APPLY + '(1 2 3 4)) ;== (+ 
1 2 3 4)  and '+ is coded to handle variable arguments.
In scheme the parenthesis tell the function where the expression 
ends. In rebol the number of arguments tell the function where the 
expression ends. This is a very fundamental difference and the tradoff 
made when dropping parenthesis or any kind of expression delimiter.
Maxim
20-Dec-2006
[1760x2]
exactly.
but we can just implement our functions with a single block argument 
if we wish... then its a moot point... no?
JaimeVargas
20-Dec-2006
[1762x2]
No. Because now you need to be passing blocks everyware. And doing 
composing for symbol to value replacement everyware.
For example:  1 + 2  becomes + [1 2], and then how you handle + [a 
b]. You need a prebinde code. Basically that reitroduces parens.
Maxim
20-Dec-2006
[1764x5]
yes obviously, actually calling reduce all the time.
I've often wondered if I missed variable args, and it seems I don't 
miss them that mutch.  they seem less needed in rebol.
but refinements are hard to reapply.
which is why I then use blocks as above.
I guess it could be nice if the burden of calling reduce where on 
the function itself.
JaimeVargas
20-Dec-2006
[1769]
I actually like the ability of having variable args. It is very handy.
Maxim
20-Dec-2006
[1770x3]
in the example of a function which accepts one variable length block, 
it could cause the prebind (reduce) itself as a pre-entry operation.
in this case it would allow a parens-like calling method, but we'd 
use blocks and the caller would not need to reduce the value explicitely.
obviously, the function args spec would have to be expanded a little.
JaimeVargas
20-Dec-2006
[1773x4]
(apply * (map + item-order-list  item-price-list)) for example (apply 
* (map + '(1 2 4) '(100 50 25)))  ;== 300

That is my one line scheme code for totalizing an order.
But if function pre-bind blocks or pre-reduce, you lose CODE-AS-DATA, 
beside making function evaluation slower.
I used such technique in my toy implementation for supporting  multimethod 
. (Found in rebol.org)
BTW. The totalizing onliner above have '* and '+ switch. Damm dyslexia.
Maxim
20-Dec-2006
[1777]
but that step is inevitable at some point even if we added parens. 
 because of the way REBOL does its binding no?
JaimeVargas
20-Dec-2006
[1778x2]
It could be replace if for example SPACE was use as delimiter.
Or maybe  a single DOT
Maxim
20-Dec-2006
[1780x2]
or.... an yet unused char !!!!     a simple comma.
but then we get code like C with line terminations ... yuk.
JaimeVargas
20-Dec-2006
[1782x4]
Exactly. The curses of *free form*.
I actually think BLANKSPACE is a good candidate.
But thinks like append "d" copy skip "cba" 2. Need to be written 
in multiple lines.
APPEND "d" \
   COPY \
      SKIP "cba" 2


Using the '\ as hint that the expression is expecion something to 
return from the next expresion.
Maxim
20-Dec-2006
[1786]
you are tooo scheme infected.
JaimeVargas
20-Dec-2006
[1787]
Nah. You alwasy do tradeoffs in Language Design.
Maxim
20-Dec-2006
[1788x3]
;-)   for my part... REBOL's code looks are a reason I like it.
one reason I'm not attracted to what I've read of scheme is the actual 
syntax.
hehe
JaimeVargas
20-Dec-2006
[1791x2]
Actually scheme is pretty much free form; after using it for a while 
you no longer see the parens. Python removed the parens but forcing 
identation. Acutally there is a scheme mode that allow you to program 
without parens.
But the issues of expression determination is faced by every language. 
C uses Semicolons,, Scheme uses Pares, Unix Shell use Pipe and others; 
and Rebol argument counting. This simple principle will determine 
what kind of expressions are possible and what you gain and what 
you lose.
Maxim
20-Dec-2006
[1793x2]
but I think just using the \ char should be enough each \ ends one 
var arg counter.
lifo ordering of arg "grabbing" should be able to determine which 
\ ends which func... AFAICT
Pekr
20-Dec-2006
[1795]
First I thought R3 alpha will be released before the end of the year, 
now I wish we could at least see long time promissed diagrams of 
R3 architecture as a Christmas gift :-))