World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Henrik 21-Jan-2008 [1227] | 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 [1268x2] | Are you an ex-forther or something ? |
(sorry, don't mean to sound rude...) | |
SteveT 21-Jan-2008 [1270] | No VB, C'# You tent to start with the object and then using . notation you tell it what action to take on it. |
Anton 21-Jan-2008 [1271] | Ah of course. Much better this way :) |
SteveT 21-Jan-2008 [1272x2] | Rebol you say what you want to do then which object you want to do it to lol |
As I said on my blog I'm just entering my second week of de-programming ;-/ | |
Anton 21-Jan-2008 [1274] | .. rebol is like: VSO = Verb Subject Object VB, C# is like: SVO = Subject Verb Object and Yoda is : OSV |
SteveT 21-Jan-2008 [1275] | Yeah your mind get comfortable one way or the other - takes a lot of breaking |
Anton 21-Jan-2008 [1276] | So actually rebol is less like english in that respect. But actually english is crazy. It's better to have the verbs at the front. |
older newer | first last |