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

World: r3wp

[!REBOL3-OLD1]

Gregg
6-Apr-2006
[246x2]
We could also say that only the first value is the default if it's 
a literal; any number of options in this line. The remaining issue 
is how to define a default datatype! value.
I think he was using a literal issue! there Max.
MichaelB
6-Apr-2006
[248]
sorry that was just because n was a issue! datatype - I thought
Maxim
6-Apr-2006
[249]
ok.
MichaelB
6-Apr-2006
[250x3]
like f: func [/opt string ["hello" string!]][print string]
just for 'word the order would be necessary
else it could be free - but this would be bad for the habit and learning
Gregg
6-Apr-2006
[253]
This is something we could mock up today, to see how we like it.
Maxim
6-Apr-2006
[254]
Michael, is your example different from what I posted last?  I see 
no difference...
MichaelB
6-Apr-2006
[255]
no :-) I see.
Maxim
6-Apr-2006
[256]
but keeping with consistency, not having any : in there does not 
seem right.
MichaelB
6-Apr-2006
[257]
where you wanna put the :
Maxim
6-Apr-2006
[258x2]
HA!  if the value is a set word?
as in f: func [/opt val: 4 [integer!]] [print val]
MichaelB
6-Apr-2006
[260x2]
one problem could be how to handle
f: func [/opt a-word [integer!]][...]
actually I kind of like this also - and wouldn't cause interpretation 
problems
Maxim
6-Apr-2006
[262]
it is very consistent with the rest of REBOL IMHO
MichaelB
6-Apr-2006
[263]
problem compared to 
f: func [/opt a-word [the-word]][...]
Maxim
6-Apr-2006
[264]
Gabriele said there might be issues with using a set word within 
the func spec block,  but if func really is a dialect... I don't 
see how.
MichaelB
6-Apr-2006
[265x2]
so what was the reason against your last (and has been before) idea 
?
ok
Maxim
6-Apr-2006
[267x2]
in any case, some words should be reserved  (like 'return)
So Gregg what do you think?
Gregg
6-Apr-2006
[269x2]
I think either one of these last two options we've come up with could 
work. I want to think about it a bit more, and others may chime in 
as well. I'm wondering if the extra block approach as easy to do, 
and had good performance, where this may have a bigger impact, but 
I like this line of thinking much better.
as easy to do = was easy to do
Maxim
6-Apr-2006
[271]
I do think that the set word approach is more approachable and much 
more readable... do you agree?
Gregg
6-Apr-2006
[272]
I'm not sure. At a glance I like it, but then I think about other 
things that we may want to do in the future, e.g. constraints.
Maxim
6-Apr-2006
[273]
constraints?
Gregg
6-Apr-2006
[274]
e.g. specify that an integer param must be positive.
Maxim
6-Apr-2006
[275x2]
honestly, Gregg, if you measure the times you'd need a default value 
wrt any other func enhancement ... I am sure default values are far 
ahead.
just about every other func I use would have default values in them. 
 hell in python I don't even recall one function which didn't have 
default values... they are just so usefull.
Gregg
6-Apr-2006
[277]
True, today, but I also know that I have a *lot* of code that validates 
parameter values, and if that could be done declaratively...
MichaelB
6-Apr-2006
[278]
one thing that is better in the [] version is that it fits with the 
current model of annotating the value in front of it
Gregg
6-Apr-2006
[279]
It's the REBOL problem of being able to do anything, and we need 
to think about how we really want to write functions IF (and that's 
a big IF) it's something that affects R3.
Maxim
6-Apr-2006
[280]
but the block also get ambiguous, as gregg pointed out, trying to 
set a default value of datatype gets pretty unobvious... and even 
quirky.
Gregg
6-Apr-2006
[281]
i.e. if we come up with a really ambitious func spec dialect, should 
we propose it now, for R4, or never (and just mezz it in for those 
who want to use it)?
Maxim
6-Apr-2006
[282]
hum... are default values part of  ambitious?
Gregg
6-Apr-2006
[283x2]
I think they're the first step on that slippery slope. :-)
Not too ambitious in themselves though, and *so* useful that I think 
it's worth pushing for it.
Maxim
6-Apr-2006
[285x2]
hehe, IMHO NOT having default values is a current REBOL shortcomming. 
 ;-)
a lot of code would get a few lines trimmed
Gregg
6-Apr-2006
[287]
I agree 100%.
Maxim
6-Apr-2006
[288]
especially if the values are reset at each function call.
Gregg
6-Apr-2006
[289x2]
Trimmed, and become much cleaner in intent.
cleaner = clearer. doh! :-)
Maxim
6-Apr-2006
[291x2]
yes, especially if the set-word approach is used... just a casual 
glance at the spec indicates something is being set.  otherwise, 
one needs to know it.
the datatype block is obvious because they are datatypes within the 
block.
Gregg
6-Apr-2006
[293]
Gotta run. Great chat guys!
MichaelB
6-Apr-2006
[294x2]
square: func [x [decimal! (x > 0) complex!]][x * x]


will be very difficult to get it right if other things should be 
allowed later :-/
should have been sqrt :-)