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

World: r3wp

[Core] Discuss core issues

btiffin
18-Feb-2008
[9208]
Check in and around http://rebol.com/docs/core23/rebolcore-9.html#section-3.2
  but note the backtick  `var is really just a single quote.
[unknown: 5]
18-Feb-2008
[9209]
don't see anthing helpful there.
btiffin
18-Feb-2008
[9210x2]
f: func ['a] [type? :a]
Note the ' on the spec and the : get in the func.    REBOL is one 
tricky little business  :)
[unknown: 5]
18-Feb-2008
[9212]
that is a direct reference.  But try something like this:

blk: ['word]

f: func [arg][lit-word? arg]

then try it:

f blk/1

And you will see the problem.
btiffin
18-Feb-2008
[9213x2]
Just for fun ... check out http://rebol.net/wiki/Glossaryand http://rebol.net/wiki/Glossary_rebols_view
for how confused I am in this area.  :)
>> d: ['junk]
== ['junk]
>> f: func [a] [type? :a]
>> f d/1
== lit-word!


You need the : get inside the func to avoid evaluating arg inside 
the function.
[unknown: 5]
19-Feb-2008
[9215x3]
Of course....why didn't I think of that....  I was racking my brain 
and didn't even think of the simple stuff.  let me see if my litlle 
function works now.
potential?: function [arg][][either all [word? :arg not lit-word? 
:arg][true][false]]

>> blk: [print 'print "print"]
== [print 'print "print"]
>> potential? blk/1
== true
>> potential? blk/2
== false
>> potential? blk/3
== false

works good!
Do we already have a function that does this? If not a similiar function 
should probably be thrown in REBOL3 don't you think?  Could be useful
btiffin
19-Feb-2008
[9218]
Paul;  I get so lost in the REBOL trees so often ... that "obvious" 
isn't in my REBOL vocabulary yet.  It's partly why I post helper 
notes;  knowing someone else will correct me and I'll learn that 
little bit more about concise REBOL.  ;)

Like from TRETBASE, I didn't even think to test   that   false = 
none  is false  and I was so glad Anton posted the "obvious".
[unknown: 5]
19-Feb-2008
[9219]
My problem is that I forgot many things because I haven't done them 
in so long.  Plus I forget what changes were made so I find myself 
doing something complicated that has now been simplified.
Henrik
19-Feb-2008
[9220x3]
I rarely use FALSE actively, more relying on that many functions 
like ALL and ANY work best with NONE. This shortens many functions.
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
[9257]
Yeah I understand how it works but the help documentation seems confusing.