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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
7-Mar-2008
[9407]
>> test: [[["this"]] [[["is"]]] ['a] 'big [[['mess]]]]
== [[["this"]] [[["is"]]] ['a] 'big [[['mess]]]]
>> flatten/full test
== ["this" "is" a big mess]
[unknown: 5]
8-Mar-2008
[9408]
I'm not sure I care for the refinement names I chose with the exception 
of /full.  I kinda like that name as it gives me a better perspetive 
of what it is doing.
Pekr
12-Mar-2008
[9409]
how can I make object words local to the context of object? I mean

obj: context [a: 1 pri: does [print a]]


I would like to be able to use 'a in the closed context, but I don't 
want it to be available via obj/a ..... I tried to enclose it to 
'use, but then it is not available to 'pri function :-)
Gregg
12-Mar-2008
[9410]
See these ML threads on REBOL.org.


http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlRJCC

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlTLVQ
Pekr
12-Mar-2008
[9411]
thanks ...
BrianH
12-Mar-2008
[9412]
Wrap the USE around the CONTEXT, rather than the other way around.
[unknown: 5]
12-Mar-2008
[9413]
This topic comes at a good time for me as I have a complex issue 
that I need to address which is similiar to what Pekr's sounds like 
except that I'm binding object/words to object/some-func.  I'm going 
to have the need to not allow someone to access object/words by probing 
object/words.  Object words is to large to have all of it inside 
of object/some-func which is why it is external to that function 
and only parts of it get bound to that some-func.
Ingo
13-Mar-2008
[9414]
I just remembered the 'self trick, don't know whether it's officially 
supported, but it works ...

given: ....

o: make object! [ 
	self: make object! [
		p: does [print [a b c d]]
		ca: func [x][a: x]
		d: 4		
	 ]
	a: 1 b: 2 c: 3
]

you have ...

>> o/p
1 2 3 4
>> o/ca 7
== 7
>> o/p
7 2 3 4
>> probe o
make object! [
    p: func [][print [a b c d]]
    ca: func [x][a: x]
    d: 4
]
>> o/a
** Script Error: Invalid path value: a
** Near: o/a
>> o/self/a
** Script Error: Invalid path value: a
** Near: o/self/a
[unknown: 5]
13-Mar-2008
[9415]
nice that is what I'm looking for.
Pekr
13-Mar-2008
[9416]
o/p is directly known? I did not know 'self allows such functionality 
:-)
[unknown: 5]
13-Mar-2008
[9417]
It's sweet for sure.  Another one of those hidden REBOL perks.
Gabriele
14-Mar-2008
[9418x2]
i don't think this is intentional, but it's something i've used quite 
a few times. basically make is returning self, whatever you make 
that be :)
>> make object! [self: "blabla"]
== "blabla"
[unknown: 5]
14-Mar-2008
[9420x3]
Objects are kinda strange.  For example, if you set 'self after you 
created the context it can be referenced but remains hidden in a 
sense:
>> obj: context []
>> obj/self: "hidden"
== "hidden"
>> probe obj
make object! [
]
>> obj/self
== "hidden"
But this highly not recommened unless your aware of what your using 
your object for as self will not refer back to itself any longer.
btiffin
16-Mar-2008
[9423]
I'd like to thank the 2.7.6 team for all the great new stuff.  In 
particular  Brian Hawley  - well done.  Kudos; the new mezz features 
are awesome.  ALSO and FIRST+ being just two of many that will make 
for more concise code.

Long Live R2.
Graham
16-Mar-2008
[9424]
Perhaps someone can post examples of how the new mezzanines are used 
...
btiffin
16-Mar-2008
[9425]
ALSO;   instead of  
    tmp: first series  series: next series  tmp
   also  first series  series: next series

No tmp required,  ALSO  will return the first result of the two expressions 
 BUT in this case why?   :) 
FIRST+;   instead of the (now) useless example I just wrote;

    first+ series    ;; return value at current reference and then advance 
    reference
No tmp, no next required.  All in one expression. 


Note:  SOURCE ALSO   it's cool and will make a lot of sense when 
you see it.
[unknown: 5]
16-Mar-2008
[9426]
Yeah the mezzanines will be very useful and should be in there just 
because of the frequency they will be used.
Graham
17-Mar-2008
[9427x2]
also: func [
    {Returns the first value, but also evaluates the second.}
    value1 [any-type!]
    value2 [any-type!]
][
    get/any 'value1
]
so, it's getting the first value .. how is it evaluating the second 
?
btiffin
17-Mar-2008
[9429]
also 1 2    1 and 2 are evaluated by the normal sequence of getting 
arguments.   This func captures the two results (simply by having 
them as arguments) and returns the first.   Love the REBOL.  :)
Graham
17-Mar-2008
[9430]
ahh... deep magic
JohanAR
17-Mar-2008
[9431]
I use the following in my program:

name: any [
	also getname var: yes
	also getanothername var: no
]


if getname fails (returns none) the other function must be called, 
and a variable set to flag this. Could ofcourse be rewritten, but 
I wanted to try using also :)
Geomol
17-Mar-2008
[9432]
ahh... deep magic

Made me think of Arthur C. Clarke's 3. law:

Any sufficiently advanced technology is indistinguishable from magic.
:-)
Graham
17-Mar-2008
[9433]
Nah .. it's CS Lewis, and Narnia
[unknown: 5]
21-Mar-2008
[9434x3]
I wish we could do something like this:

myfunc: ['notjustanyword [word! [this that]][spec block]
That way we can only pass this or that to the function otherwise 
it generates an error
Maybe I'll add that to the wish list for R4 - lol.
Henrik
22-Mar-2008
[9437]
is there any way to check whether the Windows clock has changed?
[unknown: 5]
22-Mar-2008
[9438x3]
You can do a call to net time
Doesn't REBOL read the windows time?
Guess need more information by what you mean by changed.
Henrik
22-Mar-2008
[9441]
if someone manipulates the clock or if it switches to daylight savings 
time, etc.
[unknown: 5]
22-Mar-2008
[9442x5]
Henrik those events are written into the event log on NT platforms.
Maybe that would help to query the log.
You can see those messages by going to start -> run -> "eventvwr.msc"
Should record then in the system log section.
;Here is a handy skip function:

skip+: func [
    {Returns a series matching the skip sequence}
    series [series!] "Series to return skip values from."
    interval [integer!] "Skip interval"
    start [integer!] "Series index to start skipping from."
    /local blk][
    blk: copy []
    series: at series start
    while [not tail? series][

        if (index? series) = start [insert tail blk first series start: start 
        + interval]
        series: next series
    ]
    series: head series
    if empty? blk [return none]
    blk
]
Henrik
22-Mar-2008
[9447]
hmm... can you give some examples of the skip+ function?
[unknown: 5]
22-Mar-2008
[9448x2]
>> blk: [1 2 3 4 5 6 7 8 9 10]
== [1 2 3 4 5 6 7 8 9 10]
>> skip+ blk 2 1
== [1 3 5 7 9]

>> blk: ["paul" "john" "ringo" "george" "michael" "ted" "hans" "linda" 
"sue"]

== ["paul" "john" "ringo" "george" "michael" "ted" "hans" "linda" 
"sue"]
>> skip+ blk 3 1
== ["paul" "george" "hans"]
It allows you to start at any index position in a series and begin 
returning values that match the skip interval.
Geomol
22-Mar-2008
[9450x2]
You can use EXTRACT for that:
>> extract blk 3
== ["paul" "george" "hans"]
>> extract next blk 3
== ["john" "michael" "linda"]
REBOL has so many cool functions already build in. Look here for 
them sorted by area of use:
http://www.rebol.com/docs/dictionary.html
Henrik
22-Mar-2008
[9452]
Geomol, it reminds me that R3's help function must provide hints 
to relevant functions. I've fallen into this trap many times.
[unknown: 5]
22-Mar-2008
[9453x4]
LOL geomol, I was looking all over for a function in REBOL that did 
that.
My skip function is a bit more efficient though.  Maybe we should 
replace extract with it:
>> a
== [1 2 3 4 5 6 7 8 9 10]
>> stats/evals/clear
== [2 1 2]
>> b: extract/index a 2 1
== [1 3 5 7 9]
>> stats/evals
== [218 107 33]
>> stats/evals/clear
== [219 108 34]
>> b: skip+ a 2 1
== [1 3 5 7 9]
>> stats/evals
== [187 90 39]
Looks like extract is also a bit buggy