This is not a new idea... it's a nag.
I'm inclined to add it... unless you shout loudly really soon.
Why? This pattern happens often. FOREACH already does it in R3.
Brian Hawley 1-May-2010 23:44:31 |
Having written that code pattern often, I would not dispute that change. But it would be good if empty? none returned none, rather than true or false. So we could distinguish if need be. |
Paul 2-May-2010 1:16:28 |
I agree with Brian. I would welcome the flexibility. |
Steeve 2-May-2010 4:51:47 |
Enhancing the polymorphism of basic functions is always a good choice. (I dislike the error bombing due to types not supported) |
Robert 2-May-2010 5:09:59 |
Yes, please add it. I don't how often I have written this sequence... |
meijeru 2-May-2010 5:31:03 |
It is in line with many of the series functions operating on none. So +1 for me. |
Edoc 2-May-2010 11:03:55 |
I agree on the change. I mostly write trivial rebol scripts, but this statement is very common even in basic rebol code. |
Carl Sassenrath 2-May-2010 15:33:02 |
Ok, done. A minor change, EMPTY? which was defined as:
empty?: :tail?
is now defined:
empty?: make :tail? [
[
{Returns TRUE if empty or NONE, or for series if index is at or beyond its tail.}
series [series! gob! port! bitset! map! none!]
]
]
|
Graham 2-May-2010 16:19:43 |
In R2 I use this form:
something?: func [ o [series! none!]][
all [ o not empty? o ]
]
to avoid negation in my test. |
DideC 2-May-2010 16:27:01 |
Yes, it's a good thing. |
Brian Hawley 2-May-2010 17:02:58 |
Seriously, the code Carl just posted above for the redefined empty? is even better news. You can define a function as being derived from another function, but with a different spec - even for native functions - as long as the code is compatible with both specs! Now that is going to be interesting :) |
Carl Sassenrath 2-May-2010 19:41:10 |
Ah, Brian noticed...
This feature is in prior R3 versions, but A98 fixes a couple bugs and makes it work.
These are all valid:
f2: make :f1 []
f2: make :f1 [[arg]]
f2: make :f1 [* [print arg1]]
That last line allows you to use the same spec but different body. All of these rebind (if necessary).
|
Maxim Olivier-Adlhoch 3-May-2010 10:01:04 |
wow deriving functions :-)
now if we could derive accessors ;-)
like python or javascript 5 |
Maxim Olivier-Adlhoch 3-May-2010 15:59:11 |
I'll improve on my last statement... its badly phrased.
now if we could only derive any type and play around with its accessors.
(user types anyone? :-) |
Brian Hawley 14-May-2010 15:33:22 |
Note: In alpha 98-99, empty? none returns true, not none. This means that the ability to distinguish none from an empty series when needed is done by using tail? instead, which will still trigger an error when passed none. This is better than the approach I suggested above.
See also CureCode #1611 for the corresponding proposal for index?. |
You can post a comment here. Keep it on-topic.