World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 3-Jan-2009 [11964] | For example, my function will take a series and if anything in it is a function or native then it will change that word to a literal so that it is then seen as a value. |
btiffin 3-Jan-2009 [11965] | I always wondered why REDUCE/ONLY didn't do this (an exclusion list of words or an inclusion list of words more like) |
[unknown: 5] 3-Jan-2009 [11966x4] | For example: >> defunction [print "cool" 1 * 1 2 = 2] == ['print "cool" 1 * 1 2 = 2] |
Yeah Brian, that is what would be nice to have. But not just an exclusion but also a type! such as Reduce/exclude [delete %somefile] [function!] | |
My functions works on nested series also. | |
>> s == [print "cool" do exit halt 1 * 1 [print "cool" do exit halt 1 * 1]] >> defunction s == ['print "cool" 'do 'exit 'halt 1 * 1 ['print "cool" 'do 'exit 'halt 1 * 1]] | |
Chris 3-Jan-2009 [11970] | Sounds like you need a 'map function. Psuedo-example: map my-block func [val][ either word? val [ either any-function? get val [val][get val] ][ val ] ] |
BrianH 3-Jan-2009 [11971] | A whitelist is easier to implement in R2. You create an object that has all of the legit functions assigned to fields, then load the block unbound (to-block of its string representation), then bind the block to the legit object. All other function references will be unbound in the block. Be really careful when choosing your legit functions - you might need to make safe equivalents for some. |
Chris 3-Jan-2009 [11972x2] | Not sure that is 'easier to implent'? Especially when your spec is blanket screening of all functions... |
...implement (getting more like Reichart : ) | |
BrianH 3-Jan-2009 [11974x2] | (I've been having keyboard problems that do the same thing) |
Chris, you missed that being able to screen for "bad" functions is what Paul is trying to do. It is much easier to maintain a whitelist than a blacklist, and easier to implement in R2 as well. | |
[unknown: 5] 3-Jan-2009 [11976x4] | Chris is on to the method that I deploy but I do it recursively. |
I also use an exceptions list to allow certain words. | |
>> s == [print "cool" 1 + 1 age > 18 halt all [3 + 3] find "this" "i" [print "cool" 1 + 1 age > 18 halt all [3 + 3] find "this" "i"]] >> defunction s == ['print "cool" 1 '+ 1 age '> 18 'halt 'all [3 '+ 3] 'find "this" "i" ['print "cool" 1 '+ 1 age '> 18 'ha lt 'all [3 '+ 3] 'find "... >> reduce s == [print "cool" 1 + 1 19 > 18 halt all [3 '+ 3] find "this" "i" ['print "cool" 1 '+ 1 age '> 18 'halt 'all [3 '+ 3] 'find "this" "... >> | |
I have two implements of that function | |
Henrik 4-Jan-2009 [11980x3] | I want to use the body of an object in a VID layout block, but words are not lit: things: make object! [item-type: 'something] layout compose/deep [button "Hello" with [(things)]] When words are not lit, the layout process goes wrong, because: >> probe things make object! [ item-type: 'something ; yes ] >> third things == [item-type: something] ; no! How do I get lit words there? |
oops, the layout line is supposed to be: layout compose/deep [button "Hello" with [(third things)]] | |
layout compose/deep [button "Hello" with [(load at mold :things 14)]] Dumb solution, but it works. | |
Ammon 4-Jan-2009 [11983] | >> third things == [item-type: something] >> type? second third things == word! >> things/item-type == something >> type? things/item-type == word! >> type? things/item-type: to lit-word! things/item-type == lit-word! >> third things == [item-type: 'something] >> type? things/item-type == lit-word! |
Henrik 4-Jan-2009 [11984] | yes |
Ammon 4-Jan-2009 [11985] | I vaguely remember some sort of hack I worked with Compose to come out with the correct result on item creation but I may very well be mistaken. |
Gregg 4-Jan-2009 [11986] | I've done the mold+load trick as well Henrik. I've also taken the block from THIRD and changed each word type to lit-word. change-each w third things [either word? w [to-lit-word w] [w]] |
Henrik 4-Jan-2009 [11987] | thanks, Gregg. I'm assuming now there is no truly quick way to do this. |
Maxim 4-Jan-2009 [11988] | henrik, the trick is to keep them as lit words: make object! [ item-type: to-lit-word 'something ] |
Graham 5-Jan-2009 [11989] | Have there been any efforts to standardize on IPC methods? |
Gregg 5-Jan-2009 [11990] | Not that I'm aware of, other than me bugging Carl about it. I've used a number of different methods myself (files, local TCP ports, tuplespace). |
Pekr 5-Jan-2009 [11991x2] | Graham - what do you mean by IPC? Rebol task to rebol task? |
IIRC r3 architecture counts on it, and there should be ipc:// scheme, or I think I saw something like that proposed :-) | |
Graham 5-Jan-2009 [11993] | Yes, rebol process to rebol process |
Nicolas 7-Jan-2009 [11994] | are rebol's words stored as a linked list? also, where are rebol's datatypes stored? is there a value in front of every value that is the datatype? is the datastructure stored in a separate place to the values themselves? how does it work? |
Sunanda 7-Jan-2009 [11995] | No one is really saying, Nick. It's a part of the implementation that may change at any time. Some clues have surfaced over the years in discussions about "slots" (search for [REBOL slots] for more links: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlKVVC |
Henrik 7-Jan-2009 [11996] | Can anyone explain exactly what random/secure does? |
btiffin 7-Jan-2009 [11997] | Does this help? http://www.rebol.net/cookbook/recipes/0019.html |
[unknown: 5] 7-Jan-2009 [11998] | My belief is that /secure is like /seed except much the algorithm is far stronger.than the /seed algorithm. |
Henrik 7-Jan-2009 [11999] | what does strength mean here? the number of times between two identical outcomes? |
[unknown: 5] 7-Jan-2009 [12000] | dunno. |
Sunanda 7-Jan-2009 [12001] | /secure provides its own seed. Theoretically, that seed is less guessable than the sort of things we are likely to think of in mezzanine code -- like time/precise. But we don't know for sure. All we do know is that with /seed we can provide the same seed and get the same series of random values; while with /secure if is not so easy. |
Graham 7-Jan-2009 [12002] | So, /seed is used for replicating issues ... |
Sunanda 7-Jan-2009 [12003] | That's what I use it for, anyway. Try this and see the effect: loop 5 [random/seed 100 print "start of new series" loop 5 [print random 100]] |
btiffin 7-Jan-2009 [12004] | Well, wait, the cookbook example from Carl starts with a random/seed now before calling the random/secure code. So I'm confused. |
Sunanda 7-Jan-2009 [12005x2] | I think that may be so he can later _remove_ the /seed and have secure numbers once testing is complete. Look at the *bad* effect of starting with a seed in my example: loop 5 [random/seed 100 print "start of new series" loop 5 [print random/secure 100]] |
Compared with: loop 5 [print "start of new series" loop 5 [print random/secure 100]] | |
Graham 7-Jan-2009 [12007] | change the seed! |
Sunanda 7-Jan-2009 [12008] | Or do not have one when using /secure, and expecting /secure to work! |
Graham 7-Jan-2009 [12009x2] | I usually seed with a precise time value |
so, random/seed now looks okay to me | |
Henrik 7-Jan-2009 [12011] | Graham, if you ever (ever) need to do that under win98, you must be careful, because time precision is much lower there. |
Graham 7-Jan-2009 [12012] | Umm... not sure if my stuff runs under win98! |
Henrik 7-Jan-2009 [12013] | hence, you can get the same value, if you do it again after 1/10th or 1/100th of a second. |
older newer | first last |