World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
BrianH 24-Nov-2010 [3955] | Ah, OK then. The change in issue! has brought up a lot of issues, so to speak. We are hoping to collect them all and come up with a set of tweaks and enhancements that can make things work. It should be possible to make them work a lot like they did before, with only minor changes (like being non-modifiable). You can replicate a lot of the behavior of a series type in a non-series type by simply having the series functions also work on the other type, as closely as appropriate. Good examples of these are SELECT and APPEND on objects and maps. |
Sunanda 25-Nov-2010 [3956] | I should have given the example: to-binary 33333333 As the above discussion suggests, creating an issue! is a bit of a dead end in this case. A binary! is much more usable.....That is true in R2 as well as R3. |
Duke 29-Nov-2010 [3957] | A function like: [code] func [x] [subtract 6 x] [/code] strikes me as being a lot like an anonymous function or lambda expression. Is that correct? How would I execute the above function from Rebol CLI? I keep getting error messages, so I'm not getting a piece of the puzzle. |
ChristianE 29-Nov-2010 [3958x3] | >> do func [x] [subtract 6 x] 1 == 5 >> apply func [x] [6 - x] [1] == 5 |
I'd say, yes, those are anonymous functions - in the sense that they aren't assigned to a word. But in the stricter sense of a "named" function, REBOL doesn't have that concept at all. You can assign a function to one word, some words, or no words at all. | |
Easy to see for example in code so simple as >> a: b: c: func [ ] [print "What's my name?"] >> do [a b c] | |
Izkata 29-Nov-2010 [3961] | I consider them to be the same as anonymous functions/lambdas, due to how I was introduced to that concept in Scheme - and a similar ability to have multiple words/names reference the same function, as ChristianE shows in Rebol: (define foo (lambda () (print "Hi")) (define bar foo) |
Duke 29-Nov-2010 [3962x2] | @Christian E. Thanks for the examples! In the first one, it just dawned on me that perhaps Rebol is a stack-based language - a bit like Forth et al. Didn't you just put "5" on the stack, then the "apply func" simply pops the the stack for its parameters? |
@Izkata Ithought that I smelled a lambda - maybe a la Rebol - but close enough :) | |
BrianH 29-Nov-2010 [3964] | REBOL has a stack, like most programming languages, but no explicit manipulation of it. DO function! just evaluates the arguments. One of the many gifts of using an interpreted language. |
Duke 29-Nov-2010 [3965] | @Brian So Rebol is not a stack-based language like Forth, or concatenative languages, like Joy, Cat etc? |
BrianH 29-Nov-2010 [3966] | Nope. I haven't used the others but like Cat a lot. Too bad the author has (temporarily?) abandoned the project. |
Duke 29-Nov-2010 [3967] | @Brian OK! I can get rid of _that_ mindset in trying to understand Rebol :) |
BrianH 29-Nov-2010 [3968] | REBOL is more like an interpreted Lisp, with a Forth-like direct binding model. |
Duke 29-Nov-2010 [3969] | @Brian kinda like newLisp, then - which I have dabbled in, and liked |
BrianH 29-Nov-2010 [3970x2] | newLisp is more compiled than REBOL, and has dynamic binding, which is a completely different concept. |
Unfortunately, it is a bit hard to explain direct binding to people already familiar with lexical or dynamic binding. | |
Duke 29-Nov-2010 [3972x2] | @Brian I hear you! Please don't try ;) now now. I'm still in the KISS mode as far as Rebol is concerned |
BTW, KISS refering to _me_ NOT you | |
BrianH 29-Nov-2010 [3974x2] | We all have our moments :) |
In the simple phase of your REBOL education, all you need to know is that we have something called "direct binding", where words have direct references to their values, but that in most cases it acts like lexical binding because we fake it. So write your code as if it's lexically bound until you run into problems, then come back and be new again for the next level :) | |
Duke 29-Nov-2010 [3976] | Cool! :) |
BrianH 29-Nov-2010 [3977] | I run into these next levels pretty often, usually after a conversation with Carl or Ladislav. It's no problem to be new again :) |
Ladislav 29-Nov-2010 [3978x3] | This looks simple enough to be readable just finely: http://blog.revolucent.net/2009/07/deep-rebol-bindology.html |
One thing that attracted my attention in the article: ...interesting fact about REBOL blocks: By default, their evaluation is deferred. - not being a native speaker, I do not know, whether it means the same as: ...interesting fact about REBOL blocks: They are not evaluated (i.e. understood as 'data', not as 'code'), unless an evaluation is explicitly requested. | |
(but that is just nitpicking from me, the text is fine) | |
BrianH 29-Nov-2010 [3981] | It's that terminology bug all over again. Good point, and good article. |
Steeve 29-Nov-2010 [3982] | Well, about binding in Rebol, it's not that hard to understand. The context of any word is a hidden property. Meaning it can be changed at any time. |
Ladislav 29-Nov-2010 [3983x2] | It is very hard to find the best terminology to describe the properties (like "evaluation"), exactly because they differ from the common cases in other languages. |
yes to "The context of any word is a hidden property.", but "it can be changed at any time" is a bit complicated by the fact, that it is "immutable", meaning, that you create a new word with a different context, when you want it, instead of changing the original | |
Steeve 29-Nov-2010 [3985x5] | if its an internal (silent) reconstruction we don't bother. the behavior acts like a change. a: [obj] bind a context [obj: 1] do a == 1 From my point a view the serie A has bit been modified. |
*From my point a view the serie A has not been modified. | |
And the same word OBJ got a new context | |
Ladislav, I see your point, except it's not a problem from my point of view. ;-) | |
Probably we shoold invent new vocables. instead of "direct" binding like Brian said. I would say "space" binding. in the block: b: [ a a a a ] Each word 'A' may have different contexts. Beause they occupy diffenrt locations in "space" That"s all. :-) | |
BrianH 29-Nov-2010 [3990] | Funny :) |
Steeve 29-Nov-2010 [3991] | to go further. If we admit that words may change of context during time. Then, Rebol process "spacetime" binding |
BrianH 29-Nov-2010 [3992] | Strangely enough, they don't really change binding, they are replaced with new words of the same spelling and new binding. Words are immutable, like integers. That is what Ladislav was talking about. The functionality is great, but terminology that implies that words can change binding is not really true. |
Steeve 29-Nov-2010 [3993x3] | Yeah I see your point but I still can pretend. |
It's not a spacetime law violation | |
After new binding, Even if you say that the "cell" contains (hidden)pointers to different locations in memory. The cell himself remains at the same location in the block and has the same "public" name. So that I can say : the same "cell" in the same block with the same name has a different context. | |
BrianH 29-Nov-2010 [3996x3] | Yup. |
But the interesting thing is that the immutability of words makes BIND behave differently when passed a word (which it can't modify) versus a block (which it can). So when you bind a block, you aren't modifying the words in the block, you are modifying the block itself. This is an important distinction that we shouldn't gloss over because that tends to confuse newbies later. | |
that tends to confuse -> *glossing over the distinction* tends to confuse | |
Ladislav 29-Nov-2010 [3999] | Yes, the main problem is, that the "From my point a view the serie A has not been modified." will shoot you in the foot, as demonstrated in the bindology article |
Steeve 29-Nov-2010 [4000] | yes finally, maybe I raved too much :-) |
BrianH 29-Nov-2010 [4001] | We all reach our limits there too :) |
Ladislav 29-Nov-2010 [4002] | Therefore, the introduction of "modifies" comments is needed (and useful!) |
Steeve 29-Nov-2010 [4003x2] | Instead of spacetime modification, it's spacetime travel |
hefty... | |
older newer | first last |