r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Geomol
18-Nov-2009
[15041]
Maybe better:
forall blk [change/part blk blk/1 1]
Izkata
18-Nov-2009
[15042]
Slight differences - no internal blocks are preserved in Geomol's:
>> blk: [1 [2] [3 [4]] [5 6]]    
== [1 [2] [3 [4]] [5 6]]
>> forall blk [change/part blk blk/1 1]                     
== []
>> blk
== [1 2 3 4 5 6]


My version (gives the same result as kcollins, but is in-place like 
Geomol's) only flattens one level:
>> blk: [1 [2] [3 [4]] [5 6]]          
== [1 [2] [3 [4]] [5 6]]
>> forall blk [blk: back insert blk also blk/1 remove blk]
== [6]
>> blk
== [1 2 3 [4] 5 6]
Graham
18-Nov-2009
[15043]
>> to-block form [ [ 1 [ 2] 3 ] [ 4] ]
== [1 2 3 4]
Chris
19-Nov-2009
[15044]
Another, from the 'parse school:

	parse block [
		any [block: any-block! (insert block take block) :block | skip]
	] head block
Maxim
19-Nov-2009
[15045]
this should be a native in R3... there are MANY places where this 
is both needed and its always slow.
Graham
20-Nov-2009
[15046x2]
I've got some gui code which I am loading from a text string, and 
then running it.  I am binding it to some local words which I want 
to use and that works fine.

But I also want to invoke functions in the global context and it 
can't find them.  What to do?
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. :-)