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

World: r3wp

[Rebol School] Rebol School

Geomol
16-Feb-2009
[2187]
o: make object! [t: "abc" level: length? t]
build-markup {<%o/level%>}
kib2
16-Feb-2009
[2188]
Geomol: no build-markup is called within my object. But I forget 
to say that I use "return build-markup {<%level%>}"
I don't know if I can "return" local vars ?
Geomol
16-Feb-2009
[2189]
return is normally used from within a function. So you have a function 
within your object, that returns what you say?
kib2
16-Feb-2009
[2190]
2 secs, I post the snippet
Geomol
16-Feb-2009
[2191]
>> o: make object! [t: "abc" level: length? t f: func [] [return 
build-markup {<%level%>}]]
>> o/f
== "***ERROR no-value in: level"

heh, funny! :-)
kib2
16-Feb-2009
[2192]
http://clojurepastebin.appspot.com/2005
Geomol
16-Feb-2009
[2193x2]
Seems like a binding problem.
This works:


>> o: make object! [t: "abc" level: length? t f: func [] [return 
build-markup {<%o/level%>}]]
>> o/f
== "3"
kib2
16-Feb-2009
[2195x2]
In fact, my html-handler instance is within another object.
Geomol: So, I have to refer to the object:/level as you told me before, 
that's it ?
Geomol
16-Feb-2009
[2197]
The difference is, you have level as a local to your function, I 
have level as a member of the object. What do you give to build-markup? 
It's a string, right? So build-markup don't know, what you mean by 
level, I think.
kib2
16-Feb-2009
[2198]
Yes, I give it a string. But changing to "return build-markup {<%html-handler/level%>}" 
raises the same error.
Geomol
16-Feb-2009
[2199x3]
Look at it from build-markup's viewpoint. How should it know, what 
level mean? This is a bit tricky part of REBOL, but it's also one 
of REBOL forces.
level can mean anything depending on the context.
If you write you return like this, it will work:

return build-markup rejoin ["<%" level "%>"]
kib2
16-Feb-2009
[2202]
Geomol: No, sorry I can't understand. level is defined one line before 
I use build-markup ( forget the print statement).
Geomol
16-Feb-2009
[2203]
Now we force the value of level inside the string, before the string 
is giving to build-markup
kib2
16-Feb-2009
[2204]
You're right, it works well. But I still don't understand the behaviour.
Geomol
16-Feb-2009
[2205]
In my last example, the string become something like {<%3%>}

In your example, the string is {<%level%>}. This is what build-markup 
see, and it has to figure out, what level mean. It can't figure that 
out, because level is a local of your function.
kib2
16-Feb-2009
[2206]
Geomol: you mean that build-markup is sort of blind on locals ?
Geomol
16-Feb-2009
[2207]
All functions are in a situation like this. {<%level%>} is just a 
string giving to a function.
kib2
16-Feb-2009
[2208]
I've never seen such a behavior in whatever langage I've used, but 
I'm starting to understand it : thanks for the clarification.
Geomol
16-Feb-2009
[2209x2]
Maybe you can think of it as two persons, one giving the other a 
string. The person receiving the string read "<%level%>". That person 
now have to figure out, what level mean. The person live in a context 
(the global context in this situation, because everybody can call 
build-markup). So it look up level in the global context and find 
nothing, so it gives an error.
If you instead write: rejoin ["<%" level "%>"]

then level is replaced by the value of level and a string is made, 
and this new string is sent to build-markup.
kib2
16-Feb-2009
[2211x2]
Yes, nice comparison Geomol, we see that you live in the stars :)
It's all clear now, but I shall forget about my bad habbits.
Geomol
16-Feb-2009
[2213]
Learning REBOL is also about unlearning what you're used to. :-)
kib2
16-Feb-2009
[2214x2]
and sometimes unlearning if even more difficult than learning !
is RebGUI widely used ?
Rebolek
16-Feb-2009
[2216]
I used it for one program that was used to fix translation of Windows 
Vista in 15 or 19 different languages. It depends on your definition 
of "widely".
kib2
16-Feb-2009
[2217]
Rebolek: I meant "was it a good alternative to VID ?". The only thing 
I miss in every Rebol GUI I've seen is font antialiasing.
Geomol
16-Feb-2009
[2218x3]
kib, if you run under Windows and wants anti-aliasing:

view layout [box black effect [draw [text "Hello World!"]]]
font-A: make face/font [size: 32]

view layout [box 200x100 black effect [draw [font font-A text "Hello 
World!"]]]
view layout [box 200x100 black effect [draw [pen red fill-pen yellow 
font font-A text "Hello W
orld!" vectorial]]]
kib2
16-Feb-2009
[2221x2]
Geomol: in this case, you're drawing them with AGG. Your text is 
not selectable.
But that gives me an idea : is there something like NodeBox in Rebol 
?
Geomol
16-Feb-2009
[2223]
right, you figure that part out and make a nice GUI for us! :-)
kib2
16-Feb-2009
[2224]
No problem! give me just a min ... or a year :)
Geomol
16-Feb-2009
[2225]
NodeBox? Something like splash?

do http://www.rebol.com/view/demos/splash.r
kib2
16-Feb-2009
[2226x2]
No, NodeBox is for poets : http://nodebox.net/code/index.php/Gallery
. Have a look at the Helsinki gallery : it's really beautiful.
Brendan Dawes' work is also interesting.
Geomol
16-Feb-2009
[2228x2]
ok, looks nice!
I don't know, if anyone has done something similar in REBOL. There 
are demos flying around. I made a very simple Bezier demo once:

do http://www.fys.ku.dk/~niclasen/rebol/fysik/bezier.r

It could be a start to make something better and more beautiful.
kib2
16-Feb-2009
[2230]
It's like Processing ( http://processing.org/), I like this page 
made with it : http://www.wblut.com/2009/01/27/strange-symmetry-2-lite/
Geomol
16-Feb-2009
[2231]
and REBOL got the speed, I think, if you try Cyphres demo:

do http://www.rebol.com/view/demos/cyphre.r
kib2
16-Feb-2009
[2232]
Fun! And you can had more control points I suppose ?
Geomol
16-Feb-2009
[2233]
yes, shouldn't be too hard.
kib2
16-Feb-2009
[2234x2]
Whao, cypher is really quick and beautiful.
cypher --> cyphre
Geomol
16-Feb-2009
[2236]
yup