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

World: r3wp

[!REBOL3 Proposals] For discussion of feature proposals

Andreas
13-Mar-2011
[995x2]
first, you can already pass none! as value to refinment arguments.
second, instead of your above
summed: either (something) [sum/time 1 2 (something)][sum 1 2]
just use:
t: (something)
summed: apply :sum [1 2 t t]
Marco
13-Mar-2011
[997]
instead of my above
summed: either (something) [sum/time 1 2 (something)][sum 1 2]
I wish I could use
summed: sum/times 1 2 (something) ;also if (something) is none

for every Rebol function and also for my own functions preferably 
without explicitly add none! as a required type.
Andreas
13-Mar-2011
[998]
And how would you pass NONE as a refinement argument value?
GrahamC
14-Mar-2011
[999]
if you have
amount: any [ amount 1 ]
you don't have to have the either
Oldes
14-Mar-2011
[1000x3]
Marco, we use quite often code like:

>> foo: func[/something][
[     either something [ 1 ][ 2 ]
[    ]
>> foo
== 2
>> foo/something
== 1
>>
Also isn't it better to let the authors of the functions decide if 
the functions are able to accept none! or not?
And finally, in your case, why you must use the refinement, when 
you don't use it?

my-sum: func[
	arg1 [integer!]
	arg2 [integer!]
	amount [none! integer!]
][
	arg1 + arg2 * any [amount 1]
]
>> my-sum 1 2 3
== 9
>> my-sum 1 2 none
== 3
Marco
17-Mar-2011
[1003]
in the foo function /something is a refinement and not an _optional_ 
refinement. In your my-sum function amount is not a refinment and 
my-sum 1 2 none == 3 is correct. What I am saying is that the extra 
none! adds polymorphism (but i have not investigated that too much 
so i could be mistaken), so you can write: sum 1 2 or sum 1 2 3 or 
sum 1 2 none without checking for none before calling the function.
Kaj
17-Mar-2011
[1004x2]
Ehm, the nature of refinements is that they're optional
And you can't write SUM 1 2 without a refinement if you have an extra 
AMOUNT parameter. The number of parameters is fixed in REBOL. The 
way to have optional parameters is to use refinements (or a BLOCK! 
argument)
Gregg
17-Mar-2011
[1006:last]
I don't see the benefit to the propsal at this point.