World: r3wp
[Core] Discuss core issues
older newer | first last |
Anton 1-Apr-2008 [9869x2] | Yes, you've set 'native-switch global. It appears to be used only in the enum/switch function. |
You could simply refer to system/words/switch instead. No extra variable necessary here. | |
Fork 1-Apr-2008 [9871x2] | A-ha... nice. Now here's something... can I make it so that my test-block runs the code in its body in a local context? |
I guess, use [][do :block] ? | |
Anton 1-Apr-2008 [9873x4] | No, that use would be no different than just do :block |
Because, by not specifying any use locals, you are making a context without any local words in it. | |
(ah... except 'self, but that's not important here) | |
Better than loop times [do :block] is loop times block | |
Fork 1-Apr-2008 [9877x2] | Now that one I got from a sample on the web. :) http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=timeblk.r |
Which also didn't declare start: locally... | |
Anton 1-Apr-2008 [9879] | The words in block maintain their bindings. This is what you want; the words retain the meanings from the context the user wrote them in. (ie. your locals do not affect those words because nowhere do you bind the words to any of your own contexts.) |
Fork 1-Apr-2008 [9880] | do context[do :block] ... that would give it a new context and run it there. What kind of thing would that break? |
Anton 1-Apr-2008 [9881] | So if I write test-block "section" [ print reps ] then REPS means what *I* (the user of the test-block function) thinks it means, not what test-block thinks in its little context. |
Fork 1-Apr-2008 [9882] | Hmmm. Ok, so if I want to have local variables in a test-block the context declaration would need to live there? That is different? |
Anton 1-Apr-2008 [9883] | (First DO does nothing extra, just returns the object) Again, context [do :block] is no more (except 'self) than: do :block |
Fork 1-Apr-2008 [9884] | I did try that but it didn't seem to evaluate the block |
Anton 1-Apr-2008 [9885] | You could do something like this: use [var1 var2] block or context join [var1: 100 var2: 200] block |
Fork 1-Apr-2008 [9886] | Now it's evaluating, hm. Wonder what I did before. |
Anton 1-Apr-2008 [9887] | There're lots of confusions here when starting out :) beware ! |
Fork 1-Apr-2008 [9888] | Yes! |
Anton 1-Apr-2008 [9889] | But I'm wondering why you want to subvert the meaning of the words in the block to your local meanings. |
Fork 1-Apr-2008 [9890] | Well, I have one test block after another in a line |
Anton 1-Apr-2008 [9891] | Surely you want the block to retain all its meanings ? |
Fork 1-Apr-2008 [9892x2] | I'm used to C++, so I like scopes. They make me happy :) |
So I was wondering if I could let the concept of each test-block being a scope come from test-block itself | |
Anton 1-Apr-2008 [9894] | Rebol's contexts are better ! (But scope is good for compiling.) |
Fork 1-Apr-2008 [9895x4] | Because if one test block goes: |
var: 15 | |
I don't want the next test-block to be entered with var set to 15 | |
I want it set to none initially | |
Anton 1-Apr-2008 [9899] | Oh ok, so letting set-words be locals automatically. context block |
Fork 1-Apr-2008 [9900x2] | Does context affect anything besides set-words ? |
e.g. will everything else bind the same as you would have otherwise expected? | |
Anton 1-Apr-2008 [9902x2] | No, and the set-words are searched only in the block specified (not "sub-blocks"). |
This is getting into lfunc territory, I think. | |
Fork 1-Apr-2008 [9904x2] | Yes, I was thinking I should study that |
It appears that REBOL is just more free about this by default. You make a context for a whole bunch of code, the words bind freely, and then you blow it all away on the context level. | |
Anton 1-Apr-2008 [9906x2] | The question is, how deep do you go looking for set-words ? |
Yes, much more free. And I love it that way. | |
Fork 1-Apr-2008 [9908] | Well, again, I'll say... depends on what you're trying to write. :) |
Anton 1-Apr-2008 [9909] | True, large projects need rigorous standards. |
Fork 1-Apr-2008 [9910] | I'm an EE, so my biases are going to be a certain way. In fact, I try to bring that need for structure and formalism to things that are typically thought of as unimportant for having them, e.g. GUI code. |
Anton 1-Apr-2008 [9911] | I'm all for formalism. Rebol allows many gradations from extremely free, to quite strict (if you're prepared to write some support functions like Ladislav). |
Fork 1-Apr-2008 [9912] | I worry, for instance, about the semantics of if your app starts drawing on MOUSE_DOWN and then keeps processing MOUSE_MOVE as if you are drawing until you get a MOUSE_UP... but then your app loses focus while the mouse is down (for instance, due to a window popping up or maybe the user hit alt-tab). So the app gets lost, or information gets lost, or whatever |
Anton 1-Apr-2008 [9913] | Which is great for high-speed prototyping. |
Fork 1-Apr-2008 [9914] | Yes, high-speed prototyping does seem to be REBOL's area. I've tried Awk and PHP and Perl and such and thought they were all terrible. |
Anton 1-Apr-2008 [9915] | Yes, that's very interesting, and I'm going to have to spend some more time thinking about it. |
Fork 1-Apr-2008 [9916x2] | If you mean the mouse thing, I have a blog article / screencast about it |
http://hostilefork.com/2007/11/25/lost-focus-placeholder/ | |
Anton 1-Apr-2008 [9918] | Although I had noticed apps misbehaving on refocusing, I hadn't really thought much about it. |
older newer | first last |