World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
SteveT 21-Jan-2008 [1219x3] | Yes, I'm starting to understnad dialects and domains. Bindings I'm clue-less (LOL) |
Yes on Antons one liner with the three filed and overriding the tab to filed three the 'bind' is alien to me! | |
field ! | |
Henrik 21-Jan-2008 [1222x2] | bindings are actually simply tieing a word to a list of words (a context), which is an object. outside the context, the word has no meaning, yet it can appear anywhere in code |
I believe this is how local words work in a function definition. the words don't work outside the function, because they are bound to its context. | |
SteveT 21-Jan-2008 [1224] | Right one of the fundamentals of Rebol is that Word behaviour can change or is set by what contaxt it's in ? |
Henrik 21-Jan-2008 [1225x3] | yes, by using the BIND function, you can bind a word to one or more contexts simultaneously. |
yet it can appear anywhere in code <--- actually that's a bit wrong. if the word is not defined for a particular context, then of course it's useless there. but if you use the word in the right context, for example inside an object in which it was originally created, then it will have meaning. | |
you can study this by creating objects with words in them and try to bind them to different contexts (other objects). | |
SteveT 21-Jan-2008 [1228x2] | I understand that. Are contexts just what I would call an object? |
Ah! you just answered that ;-) | |
Henrik 21-Jan-2008 [1230x4] | yes. try: |
make object! [] and context [] and see what's returned | |
or more revealing: >> source context context: func [ "Defines a unique (underived) object." blk [block!] "Object variables and values." ][ make object! blk ] | |
it's all just a big re-dress of objects. :-) | |
SteveT 21-Jan-2008 [1234] | Think I get it - It's the object oriented side of Rebol - you could say that bind is a sort of inheritance ? |
Henrik 21-Jan-2008 [1235] | more like membership. there is no real inheritance in Rebol. |
SteveT 21-Jan-2008 [1236x2] | Yes, MS always partly implemented OO in VS. they didn't think there users could handle them ! Java is more of a full OO implementation but I find you end up having to override most objects and that's not good for code re-use. |
OO is ok but it doesn't always fit the real world (or programming productivity). that's why I think OO Databases have never really been adopted! they fit models but not the real world (Where the customer say's Ahh! didn't we mention that !! (LOL). | |
Anton 21-Jan-2008 [1238x5] | This should be instructive. Type this into the console a line at a time: |
o1: context [my-word: "hello"] o2: context [my-word: "there"] o3: make object! [my-word: "SteveT"] | |
code: [] append code in o1 'my-word append code in o2 'my-word append code bind [my-word] o3 | |
print code | |
I first show two different ways of creating an object, and then I show two different ways of getting a word in an object. | |
SteveT 21-Jan-2008 [1243] | I got a halt-view near my-word? |
Anton 21-Jan-2008 [1244x3] | Show me the code and resulting error. |
Maybe you missed one of the single-quotes before a 'my-word (which makes it a lit-word!) | |
eg. in o1 'my-word ; <-- don't miss the ' | |
SteveT 21-Jan-2008 [1247] | o1: context [mu-word: "hello"] >> o2: context [my-word: "there"] >> o3: make object! [my-word: "SteveT"] >> code: [] == [] >> append code in o1 'my-word == [none] >> append code in o2 'my-word == [none my-word] >> append code bind [my-word] o3 == [none my-word my-word] >> print code none there SteveT Yep think so that 's what i got now |
Anton 21-Jan-2008 [1248] | first line says "mu-word" :) |
SteveT 21-Jan-2008 [1249] | Dohhh! it's this eclectic keyboard lol |
Anton 21-Jan-2008 [1250x6] | 'my-word is therefore not in o1 and so: in o1 'my-word == none |
:) | |
first o1 first o2 | |
Lists the words in each object, if you don't believe what IN is telling you. | |
Or of course you can use HELP or ?. | |
? o1 ? o2 | |
SteveT 21-Jan-2008 [1256] | Think I understand that |
Anton 21-Jan-2008 [1257] | Each word carries its binding with it. ie. a reference to an object. (or no object if it is unbound). |
SteveT 21-Jan-2008 [1258] | Can you get problems if an object gets bound to itself? |
Anton 21-Jan-2008 [1259x2] | An object is a container of word -> value pairs. When you ask for a word's value, the word's binding is checked to get the object. |
An object cannot be bound to anything. Only words can be bound. | |
SteveT 21-Jan-2008 [1261] | Sorry that's what I meant 'Word' |
Anton 21-Jan-2008 [1262x2] | A word isn't really a binding target, so you can't bind a word to itself (or any other word.) |
(BIND accepts a known-word argument. It is the *object* that the known-word is from, not the known-word itself, which is the target for the bind.) | |
SteveT 21-Jan-2008 [1264] | Right - the context it's from ???? |
Anton 21-Jan-2008 [1265x2] | Correct. (context = object). So my above example could be modified to: append code bind [my-word] in o3 'self which is in fact how we used to have to do it, because BIND didn't have object! in list of accepted types for its known-word argument. |
so these are all the same: append code bind [my-word] o3 append code bind [my-word] in o3 'self append code bind [my-word] in o3 'my-word (we would use the 'self word because it's in every object by default.) | |
SteveT 21-Jan-2008 [1267] | The order of execution throws me more than anytihing I would have had to do your code like this code append bind(my-word etc) I'm so used to starting with the item |
Anton 21-Jan-2008 [1268] | Are you an ex-forther or something ? |
older newer | first last |