World: r3wp
[Core] Discuss core issues
older newer | first last |
Graham 20-Nov-2009 [15047] | eg. the text is button "test" [ alert "hello" ] and I get an error clicking on the button. |
Chris 20-Nov-2009 [15048] | Bind the loaded text to a global word first ('system ?) then to your local context. |
Graham 20-Nov-2009 [15049] | So, here, how would I get this working? test: func [ /local lo ][ lo: {button "test" [ alert "hello" ]} view layout to-block lo ] |
Chris 20-Nov-2009 [15050] | test: func [ /local lo ][ lo: {button "test" [ alert "hello" ]} view layout bind to-block lo 'all] |
Graham 20-Nov-2009 [15051] | Let me try that ... |
Chris 20-Nov-2009 [15052] | Just don't use 'all in your local context. |
Graham 20-Nov-2009 [15053] | currently I am binding the block to some local words in the context |
Chris 20-Nov-2009 [15054] | Bind to 'all first, then your local word(s) |
Graham 20-Nov-2009 [15055x2] | eg ... |
this is user written gui code which is why I bind to the local context to prevent them doing stuff that I think might be dangerous. But I want to allow some exceptions. | |
Chris 20-Nov-2009 [15057] | Assign the global functions to local words: context compose [alert: (:alert)] |
Graham 20-Nov-2009 [15058x2] | this doesn't work ... test: func [ /local lo alert] compose/deep [alert: (:alert) dummy: none lo: {button "test" [ alert "hello" ]} view layout bind to-block lo 'dummy] |
dummy should be local too | |
Chris 20-Nov-2009 [15060] | Yeah, not sure why - do you get "alert has no value" ? |
Graham 20-Nov-2009 [15061] | ** Script Error: alert word has no context ** Where: func [face value][alert "hello"] ** Near: alert "hello" |
Chris 20-Nov-2009 [15062x2] | do-protected: use [alert][ alert: get in system/words 'alert func [txt][do bind to-block txt 'alert] ] do-protected {alert "Foo"} do-protected {print "Foo"} |
So in theory it works, next how to apply to your function. | |
Graham 20-Nov-2009 [15064x3] | Not working in my function yet. |
this works test: func [ /local lo alert dummy] compose/deep [alert: get in system/words 'alert dummy: none lo: {button "test" [ alert "hello" ]} view layout bind to-block lo 'dummy ] just not working in my script though | |
oh .. remove the compose/deep | |
Chris 20-Nov-2009 [15067x4] | Hmm, try this: |
isolate: func [words [block!]][ use words compose/only [ set (copy words) forall words [change/only words get words/1] first (copy words) ] ] do-protected: func [txt allowed][do bind to-block txt isolate allowed] | |
do-protected {print "foo"} [print] do-protected {alert "foo"} [print] | |
'isolate takes a block of words, creates an exclusive context, sets words in that context to their value in their current context and returns a word bound to that context. | |
Graham 20-Nov-2009 [15071] | In your code above, allowed is not a block of works |
Mchean 23-Nov-2009 [15072] | some nice css - html expansion macros http://www.smashingmagazine.com/2009/11/21/zen-coding-a-new-way-to-write-html-code/ |
amacleod 24-Nov-2009 [15073] | A quick look at it - reminded me a little of Henrik's HTML Dialect |
Henrik 24-Nov-2009 [15074] | I bet the guy who wrote that also likes regexp. :-) |
Graham 25-Nov-2009 [15075] | Any easy way to detect whether running 32 or 64 bit windows? |
BrianH 25-Nov-2009 [15076] | On WinXP 32bit: >> get-env "ProgramFiles(x86)" == none On Win7 64bit: >> get-env "ProgramFiles(x86)" == "C:\Program Files (x86)" Really, any non-none string value returned will signal 64bit. |
Graham 26-Nov-2009 [15077] | cool |
Janko 27-Nov-2009 [15078x3] | I have one question .. I don't want somebody to surprise me tomorrow on talk about rebol... if you use the "with" pattern for example for pop protocol with-pop-do: func [ mbox addr code ] [ set :mbox open addr do code close get :mbox ] |
with-pop-do 'box get-pop-addr [ pages: "something" ] | |
and define a variable/word "pages" in the block like I did .. this word changes the global binding probably? which is not very good because it might owerride some other binding ... am I correct and is there some elegant way to not introduce such negatiev side of this otherwise elegant pattern? | |
Geomol 27-Nov-2009 [15081] | Something like this? use [pages] [ with-pop-do 'box get-pop-addr [ pages: "something" ] ] |
Janko 27-Nov-2009 [15082x3] | aha.. interesting.. I never knew what use does |
I could also use "use" in definition of with-pop-do so that the external code is most beautifull | |
thanks a lot | |
Henrik 27-Nov-2009 [15085] | you can also wrap stuff in contexts, but it requires that you specify your vars as set-words. |
Brock 30-Nov-2009 [15086] | @Janko: How did your talk about Rebol go today? |
Janko 1-Dec-2009 [15087x2] | Brock: it went okeyish ... otherwise it was great and I did sew some pushed out eyes (from few python programmers) towards the end. The problem was I had very programmer / code - centric presentation , where I was hoping to give (better) coders some clue what and how REBOL is different, but when I asked how many of them were programmers it was just like 20% or less . So I had somewhat hard time trying to show details of code and tons of code examples imagining that the most of listeners will have no clue whatsoever about what I'm talking ... |
I see now that I should just focused my thoughts on those guys who were programmers instead of seeing all the nonprogrammers not understanding a thing I was saying. Basically I missjudged the audience. And there would probably be more programmers if there werent two very interesting talks with known names at the same time as mine. | |
Henrik 1-Dec-2009 [15089x2] | some pushed out eyes <- I would have loved to see that :-) |
but overall, if you make just 2-3 people interested at the same time, that's a big thing for us. :-) | |
Janko 1-Dec-2009 [15091] | I am not joking about "pushed out eyes" ... I saw 2 that were programmers that were towards the end really intenselly looking at code I was showing and how I'll explain it. the whole thing about read http:// read %file ... open pop:// and process it as serries qute impressed one guy When I ended a couple of other programmers aproached me and asked me how this can be installed and if it's free etc .. and one pythonista said that email sending really impressed him, but otherwise he doesn't know yet .. there were also questions like "why this and not python" and "community size" and I had some explaining to do about code is data / data is code big deal |
Henrik 1-Dec-2009 [15092] | It makes me think that the process of downloading and installing REBOL is a great demo in itself. |
Janko 1-Dec-2009 [15093x4] | Yes, I was thinking of putting the scripts there but then a lot less people would see it.. you know how people are .. first and foremost LAZY |
When I asked how many were programmers and only 4 raised hands I almost wanted to stop talking because from that point on almost all slides are code and at the end I was trying to look at concrete scripts which I was worried also coders won't understand so quickly after finding out at rebol | |
not almost wanted, but serriously considered it .. but it was ok at the end .. it was a little stupid to all the nonprogrammers probably | |
I posted a link to screencast of slides in advocacy | |
older newer | first last |