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

World: r3wp

[Core] Discuss core issues

Henrik
19-Feb-2008
[9221x2]
potential?: func [arg][all [word? :arg not lit-word? :arg]]
However, I think the function would work better like:

potential?: func [arg][all [any-word? :arg not lit-word? :arg]]
[unknown: 5]
19-Feb-2008
[9223x4]
Yeah I just threw it out there as I had it in the console at the 
moment but feel like it could be of benefit to have it built into 
R3 as a mezz or something.
Your functions are returning none so I don't think we want that.
;Mabye this:


potential?: func [arg][if all [any-word? :arg not lit-word? :arg][return 
true] false]
Seems to work ok:

>> blk: [print "print" 'print]
== [print "print" 'print]
>> potential? blk/1
== true
>> potential? blk/2
== false
>> potential? blk/3
== false
Ingo
19-Feb-2008
[9227x2]
potential?: func [arg][found? all [any-word? :arg not lit-word? :arg]]


blk: [print 'print "print"] print potential? blk/1 print potential? 
blk/2 print potential? blk/3
true
false
false
... just to be part of the game ;-)
[unknown: 5]
19-Feb-2008
[9229x3]
There you go Ingo!
I forgot about found.
Just when I was starting to think there was no longer a use for it.
Ingo
19-Feb-2008
[9232]
I admit, I had to look it up, too.
[unknown: 5]
19-Feb-2008
[9233x2]
lol - I kept thinking in my head what I can return this back with 
that would explicitly evaluate to true or false and not give none 
but you FOUND it - pun intended.
So does anyone else think potential? should be a mezz function?  
If so, what should the name of it be proposed as?
Ingo
19-Feb-2008
[9235]
I'm not sure it's needed often enough to warrant its inclusion, first 
take at a name: 

non-lit-word?
[unknown: 5]
19-Feb-2008
[9236]
But it that really doesn't give an indication of what the function 
is for which I believe the function is for is to find if an argument 
has a potential to be evaluate
Henrik
19-Feb-2008
[9237]
Your functions are returning none so I don't think we want that.

 <-- my point was that NONE can be more useful than FALSE and gives 
 simpler code, if you are not using NONE as a specific value.
[unknown: 5]
19-Feb-2008
[9238]
Can you provide an example Henrik?
Henrik
19-Feb-2008
[9239]
I gave it above. Simplified code.
[unknown: 5]
19-Feb-2008
[9240]
Yeah but that is a trade off to useability in my opinion.  For example 
I can say pick [this that] potential? arg
Henrik
19-Feb-2008
[9241x2]
true, if you need to do that.
but what if you don't? :-)
[unknown: 5]
19-Feb-2008
[9243]
I think we will have to do that more than the situation where we 
would desire it to return none is why I mention it.
Henrik
19-Feb-2008
[9244]
ok, then ignore my suggestion :-)
[unknown: 5]
19-Feb-2008
[9245]
I didn't ignore it - I just want to make sure if we propose it then 
it meets the highest amount of usability.  I'm interested in all 
ideas.
Ingo
19-Feb-2008
[9246x2]
Sorry, just going nuts ...

able-to-have-a-valus?

or in short:

valuable?
valus? = value? of course ...
[unknown: 5]
19-Feb-2008
[9248x3]
I like valuable?
Ingo, do I have your ok to submit your form of the valuable? function 
via Rambo?
Anyone know why the case function has a /all refinement?  Seems the 
/all is what case does by default.
Ingo
19-Feb-2008
[9251x3]
Sure you have my OK.
I see a difference ...


>> case/all [1 probe 1 2 probe 2 3 probe 3 false probe false 5 probe 
5]  
1
2
3
5
== true

>> case [1 probe 1 2 probe 2 3 probe 3 false probe false 5 probe 
5]      
1
== 1
Bye, I'll leave for now.
[unknown: 5]
19-Feb-2008
[9254]
Yeah I am confused by the wording as it says for the /all:

Evaluate all cases

and for the function itself:

Evaluates each condition

That sounds the same.
btiffin
19-Feb-2008
[9255x2]
case will normally stop after the first true condition.  case/all 
will evaluate all of the true conditions.
The key bit from the HELP is REFINEMENTS:
     /all -- Evaluate all cases (do not stop at first true case)
[unknown: 5]
19-Feb-2008
[9257x2]
Yeah I understand how it works but the help documentation seems confusing.
would be nice to also break out of one of evaluated cases.
btiffin
19-Feb-2008
[9259]
There is always a REBOL way  :)  And after I post this, someone else 
will come by with the real answer.
 

>> print catch [case/all [true [print 1] true [print 2] true [throw 
"4"] true [5]]]
[unknown: 5]
19-Feb-2008
[9260x2]
that will work btiffin.
That seems rather clean also.
Ingo
20-Feb-2008
[9262]
How about the following wording for case? 


Evaluates conditions until the first is true, then evaluates what 
follows it.
[unknown: 5]
20-Feb-2008
[9263x5]
Makes it sound a bit like the first condition must be true.
Evaluates each condition until true, then evaulates what follows 
it.
Then again that one makes it sound like all conditions must be true.
Evaulates conditions until a condition is true, then evaluates what 
follows it.
That sounds less confusing.
Ingo
20-Feb-2008
[9268x2]
Evaluates conditions until a condition is true, then evaluates the 
associated value.
("what follows it" could be all the rest ...)
[unknown: 5]
20-Feb-2008
[9270]
So let me play newbie for a moment.  If I see your phrase I might 
think that case is going to evaluate each condition until that condition 
is true and then evaluate what follows it.  Similiar to an until 
function.