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

Ladislav
30-Jan-2011
[971x2]
You talk about is so much that someone could write an extension in 
the same time and give a real prove:) What I can say, using additional 
serie is a big speed enancement.

 - actually, it has been proven already, just look at the performance 
 of the UNIQUE, etc. functions
That is why I do not understand, why it is so hard to understand.
BrianH
31-Jan-2011
[973x2]
ALIAS function removed in the next version; see http://issue.cc/r3/1163
http://issue.cc/r3/1164http://issue.cc/r3/1165and http://issue.cc/r3/1835
for details. Also, http://issue.cc/r3/1212dismissed as unnecessary 
now.
R3 still uses case aliasing internally for word case insensitivity, 
but there is no other aliasing.
Maxim
31-Jan-2011
[975x2]
unfortunately, in the extensions, case insensitivity doesn't work.
(unless its been fixed in the very latest versions)
BrianH
31-Jan-2011
[977x2]
Do you mean in object contexts, or the words block?
Either way, report it.
Maxim
31-Jan-2011
[979x2]
word blocks for sure, didn't test on objects.
I will, next time I play on the hostkit.  right now I coudnt' provide 
example code which demonstrates it.
BrianH
31-Jan-2011
[981]
A report like "Words are not case insensitive in extension word blocks" 
would help a lot. Carl has been bug fixing lately, and that includes 
extension bugs.
Maxim
31-Jan-2011
[982]
ok... will add that to begin.
BrianH
31-Jan-2011
[983]
Please check if an object can be used by extension code to resolve 
the case aliases. I don't really see how they could if the words 
are translated to numbers at command call time, but that might be 
a limit of my imagination.
Maxim
31-Jan-2011
[984]
done.
BrianH
31-Jan-2011
[985]
That should help.
Maxim
31-Jan-2011
[986]
;-----------------
	;-     swap-values()
	;

 ; given two words, it will swap the values these words reference 
 or contain.
	;-----------------
	swap-values: func [
		'a 'b 
		/local c
	][c: get a set a get b set b  c]


>> a: 5
>> b: 1
>> if a > b [swap-values a b]
>> a
== 1
>> b
== 5


I've been using this to make sure inputs are properly ordered or 
ranges normalized when it matters further down in the code.
Gregg
16-Feb-2011
[987]
I have my own versions of the series comparison funcs Max proposed 
on 27-Jan. My versions of SHORTEST and LONGEST take a block of series 
values, and return the given item by length. I don't use them much, 
but there are times they are nice to have.
Marco
13-Mar-2011
[988]
Every refinement with an optional value should accept also a none! 
(implied ?)
eg.
sum: func [
    "Return the sum of two numbers."
    arg1 [number!] "first number"
    arg2 [number!] "second number"
    /times "multiply the result"
    amount [number! none!] "how many times"
][	; test argument, NOT refinement
    either amount [arg1 + arg2 * amount][arg1 + arg2]
	; or if not amount [amount: 1] arg1 + arg2 * amount
	; or amount: any [amount 1] arg1 + arg2 * amount
]
so it would be possible to do:
summed: sum/times 1 2 (something) ;also if (something) is none

and obviously also:
summed: sum 1 2

instead of:
summed: either (something) [sum/time 1 2 (something)][sum 1 2]
Andreas
13-Mar-2011
[989]
apply :sum [a b (something) c]
Marco
13-Mar-2011
[990]
Where is the multiplication?
Andreas
13-Mar-2011
[991]
>> foo: func [/bar x] [either bar [x] [99]]
>> apply :foo [(2 < 4) 123]
== 123
>> apply :foo [(5 < 4) 123]
== 99
Marco
13-Mar-2011
[992]
Sorry but you are flying too high for me. I am tring to rewrite my 
sum function using aplly but do not understand how it could be done.
Andreas
13-Mar-2011
[993]
you don't rewrite sum, you rewrite your call of sum
Marco
13-Mar-2011
[994]
The question is to have a simple method of calling whatever function 
which accpets an optional argument without rewriting the code that 
calls it evry time.
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.