World: r3wp
[Rebol School] Rebol School
older newer | first last |
Henrik 8-Feb-2009 [1638] | and objects are contexts. when wrapping set-word!s in contexts, they stay inside that context. |
Geomol 8-Feb-2009 [1639] | Henrik, no, not really because of garbage collection, because the garbage collector doesn't collect words defined 'globally', right? I do it, because it's good programming practise to not have many globals. :-) |
kib2 8-Feb-2009 [1640] | Henrik: that' seems a good way to handle namespaces ? |
Henrik 8-Feb-2009 [1641x2] | kib2, you'll find that many scripts come wrapped in contexts. this is the best we can do until R3 brings us modules. contexts are not waterproof, though. |
context [ a: 1 ; only inside context set 'b 2 ; global ] This can be useful, if you want to create an object with one "public" function. | |
Janko 8-Feb-2009 [1643] | >> 3 + 2 == 5 >> 3x2 + 2x3 == 5x5 |
Henrik 8-Feb-2009 [1644x2] | Geomol, true. In some extreme cases however, I've experienced crashes, because too much garbage collection happens. I always had to solve it by converting some locals to globals. |
kib2, since you can bind contexts everywhere, even inside other contexts, they are not really secure and so you can't make things really private to a context. Modules will do that, I believe. | |
Geomol 8-Feb-2009 [1646] | Henrik, ok got it. Well, in huge programs (like RPaint), I try to avoid garbage collection as much as possible. Garbage collection always works against performance, so it's bad in real-time applications (multi-media, games, etc.). |
Janko 8-Feb-2009 [1647] | + in this two cases "dispatches" on the type of arg... but this is probably handlede inside + , so if you define new type (vector3d) you couldn't make + work for that datatype too without changing it ... in multiple dispatch + is a generic word and you add definitions for it for that datatype so it can work on them without changing or having access the original + (basically similar to what is operator overloading at static lang, here it dispatches in runtime based on type) |
Henrik 8-Feb-2009 [1648x2] | Janko, I think you would solve that with typesets. |
OTOH, maybe not. the function itself must support whatever argument is passed to it. | |
kib2 8-Feb-2009 [1650] | Is there any quickref card for Rebol somewhere ? |
Henrik 8-Feb-2009 [1651] | kib2: The word browser is pretty good. It's inside the Viewtop under REBOL/Tools, I think. |
kib2 8-Feb-2009 [1652] | ok thanks! |
Geomol 8-Feb-2009 [1653x2] | Janko, I've been thinking about this problem too, and I'm not sure, what's best. Is it good enough, what we can do with functions today? Like: >> old-add: :add >> add: func [a b] [either string! = type? a [join a b] [old-add a b]] >> add 4 5 == 9 >> add "Hi " "John" == "Hi John" Now ADD can also be used to join strings. |
kib, I often use the REBOL dictionary: http://www.rebol.com/docs/dictionary.html | |
kib2 8-Feb-2009 [1655] | Geomol: that's exactly what I was looking for! |
Janko 8-Feb-2009 [1656x3] | fictional example I made up: |
make-type dog! make-type cat! make-generic 'say say: func [ a [ dog! ]] [ "woof" ] say: func [ a [ cat! ]] [ "meov" ] | |
or no.. say: woulnd't be good .. something like | |
Geomol 8-Feb-2009 [1659] | Janko, yes, that would be cool to do. |
Janko 8-Feb-2009 [1660] | make-type dog! make-type cat! make-generic 'say [ a [ dog! ]] [ "woof" ] make-generic 'say [ a [ cat! ]] [ "meov" ] |
Henrik 8-Feb-2009 [1661] | kib2, note: the web based dictionary is older and less updated than the word browser, but it works OK. |
Geomol 8-Feb-2009 [1662] | kib, to avoid confusion, remember that everything in REBOL is a word. The word in itself doesn't have a certain meaning. The words have meaning, when used in a context. The same word can mean different things in different contexts. And you can redefine everything, even things like: + and - |
Janko 8-Feb-2009 [1663] | Geomol: something like you and I described would probably be possible to do in library , probably not that effective but it should surely be possible |
Geomol 8-Feb-2009 [1664x4] | When thinking deeper, I'm not even sure, what I just said is completely true. haha |
Isn't REBOL wonderful!? ;-) | |
I guess, a number like 1 can't be said to be a word, and it can't be redefined. But you can make a dialect, in which 1 means something else. So you have words, numbers, blocks, etc. The words can be redefined to suit your needs. | |
kib, you should also read about all the values at some point, appendix 1 in the Users Guide: http://www.rebol.com/docs/core23/rebolcore-16.html | |
kib2 8-Feb-2009 [1668] | Geomol: That's really cool; data is code and vice versa, like in Lisp ? |
Geomol 8-Feb-2009 [1669x2] | I don't know much about Lisp, but I guess, yes. |
Crazy example: >> set '+ :- >> 5 + 3 == 2 | |
kib2 8-Feb-2009 [1671] | so is there something like quotations in Lisp ? ie something to get a word not to be evaluated |
Henrik 8-Feb-2009 [1672x2] | yes, "code is data is code" is essential to REBOL. |
that's lit-word | |
kib2 8-Feb-2009 [1674] | Geomol: you answered my question ! It's the ' operator, that's it ? |
Geomol 8-Feb-2009 [1675x2] | yes |
>> a: 2 == 2 >> b: a == 2 >> c: 'a == a | |
kib2 8-Feb-2009 [1677x2] | hehe |
wondeful | |
Steeve 8-Feb-2009 [1679] | oh cool... Kib2 our french math professor (I was worried that you quit too early Rebol) |
kib2 8-Feb-2009 [1680] | Steeve: In fact I've leaved because Carl was not in the mood for releasing a public R3 (see my posts on his blog). Then he was kind enough to change his mind... |
Steeve 8-Feb-2009 [1681] | i saw your comments, that's why i was soo worried ;-) |
Janko 8-Feb-2009 [1682] | also blocks don't evalueate , thats thy you can make your own >>do-five-times [ print "ups" ]<< which is a stupid example :) |
Steeve 8-Feb-2009 [1683] | Kib2, is that your blog ? it's nice http://thewrongsideofcode.blogspot.com/ |
kib2 8-Feb-2009 [1684] | Steeve : you don't have too. I'm playing with it at the moment (with R2), and I really enjoy it. |
Geomol 8-Feb-2009 [1685] | I think, that's one of the biggest reasons, we stick around with REBOL. Suddently it's very much fun programming again. :-) |
kib2 8-Feb-2009 [1686x2] | Janko: I like this, and in fact it's also the Factor way of doing things. |
Steeve: that was mine (I've 3 posts then I've stopped it) | |
older newer | first last |