World: r3wp
[Core] Discuss core issues
older newer | first last |
Volker 6-Jan-2006 [3139x2] | Not completely - the code still needs access to the global context. if you bind every word in an own context and put selected functions there, it would work. Still tricky, for example 'second can not be exposed, else you get the functions body. I may forget other issues. |
BTW would be nice if secure would support ulimit-calls. | |
MichaelB 6-Jan-2006 [3141x2] | That's one of my problems if I would like to have capability security in Rebol - all these omnipotent (is this the right word?) words, shouldn't be allowed - eg. only if my code gives out the right to introspect itself something like 'second should be calleable. |
what does that mean ? the secure thing ? | |
Volker 6-Jan-2006 [3143x2] | something like secure [file quit %./public allow memory 2000 timeout 2] |
There are cals for such restrictions in linux AFAIK, could be used on osses whith such features. | |
JaimeVargas 6-Jan-2006 [3145] | Ah. MichaelB, You want E. |
Volker 6-Jan-2006 [3146] | Can E restrict runtime too? To kill infinite loops? |
JaimeVargas 6-Jan-2006 [3147] | Don't know E. Only know that E offers the capability model. BTW, Infinite loops are only a worry if they consume resources. You could in theory always have lazy loops (which are infinite by default). |
Volker 6-Jan-2006 [3148x2] | I want to run user-code for a request. Would prefer if that finishes after a while. Or, to resrict cpu-usage at least. Hmm, i guess e has threads, so could use a guard-thread maybe. if killing that is secure. |
Is there a web-server in e? To use rebol thru cgi-style api? | |
JaimeVargas 6-Jan-2006 [3150] | lazy infinity loops == threads, almost. |
Volker 6-Jan-2006 [3151] | Do you know how to do cgi-style-calls in c? where c and rebol communicate thru kind of bidirectional pipeline? |
MichaelB 6-Jan-2006 [3152] | I'm no E expert - just know it from reading - but I like the capability model. So I guess E has nothing to restrict the runtime - I thought due to the fact that it can't be predicted, whether a computation stops, there will be anyway always some "hole". But I would like to have some restrictions on CPU usage say for windows (as Solaris seams to have it) - can't stand that copying some files can kill the whole system. But maybe this is something what doesn't belong to the language but to the OS offering the foundation ? |
JaimeVargas 6-Jan-2006 [3153] | But language can help here. |
MichaelB 6-Jan-2006 [3154] | Jaime as you talked about Haskell lately: if I remember correctly it has lazy evaluation, so would this help in the general case ? Was this what you were pointing to ? |
JaimeVargas 6-Jan-2006 [3155x3] | Yes. I think that anyone will benefit from reading this: http://mitpress.mit.edu/books/chapters/0262220695chap1.pdf (It inspired me to write make-instance). |
BTW I just changed make instance to use closures. I like it better. | |
make-instance: closure [ class [object!] /local class-vars instance-data class-methods v ][ class-vars: copy [*-private-*] class-methods: copy [] instance-data: copy [] foreach w next first class [ either function! = type? v: get in class :w [ append class-methods compose/deep [ (to set-word! :w) func [(first :v)] [ bind second get in class (to lit-word! :w) '*-private-* do reduce [get in class (to lit-word! :w) (first :v)] ] ] ][ append class-vars :w append instance-data reduce [to set-word! :w :v] ] ] use class-vars compose/deep [ (instance-data) context [(class-methods)] ] ] | |
MichaelB 6-Jan-2006 [3158x2] | maybe a stupid question, but is this chapter out of that book http://www.amazon.com/gp/product/0262220695/qid=1136588064/sr=8-1/ref=pd_bbs_1/102-4260152-7911319?n=507846&s=books&v=glance ?? |
Another thing that would interest me, is how is the speed impact when using your above function, now even with closures - I mean the closure function copies everything on invocation and also make-instance itself binds everytime anew? | |
JaimeVargas 6-Jan-2006 [3160x3] | It is going to be slower, but not that bad. |
>> time-block [CounterClass/bump] 0.05 == 4.234619140625E-6 >> time-block [ctr1/bump] 0.05 == 1.17197799682617E-5 >> a: 4.234619140625E-6 == 4.234619140625E-6 >> b: 1.17197799682617E-5 == 1.17197799682617E-5 >> a / b == 0.361322409814242 >> b / a == 2.7676113433266 | |
It is slower because of binding | |
MichaelB 6-Jan-2006 [3163] | But not that much, given all the stuff that happends. |
Volker 6-Jan-2006 [3164x2] | do reduce [get in class (to lit-word! :w) (first :v)] -> do get in class (to lit-word! :w) (first :v) ; should work too |
either function! = type? v: get in class :w [ -> either function? v: get in class :w [ | |
JaimeVargas 6-Jan-2006 [3166x2] | Optimizations welcome ;-) |
It improved but not by much. | |
Henrik 7-Jan-2006 [3168x2] | ah the joys of BIND... >> a: make object! [b: 0 c: b] >> a/b == 0 >> a/c == 0 >> set in a 'b 7 == 7 >> a/c == 0 How do I restore the context? |
wait... that's not the problem | |
BrianH 7-Jan-2006 [3170x2] | The context is fine. When you do c: b you are setting c to the value of b (or rather a copy, since 0 is an immediate value). When you change the value of b the copy of the old value remains the same in c. |
Bind isn't used here. | |
Henrik 7-Jan-2006 [3172] | I realized that just now. the problem was entirely different. |
Robert 7-Jan-2006 [3173] | question concerning 'get: First, why doesn't get support something like "get my-object/user-data"? Next, how to get a path word? |
Henrik 7-Jan-2006 [3174] | path word? such as in my-object 'user-data ? |
Robert 8-Jan-2006 [3175] | Forget the last question... |
BrianH 12-Jan-2006 [3176] | Does the file execute setting of the secure native mean anything on Windows. What is it supposed to mean? |
Pekr 13-Jan-2006 [3177x4] | how to easily do base conversion? e.g. working with bitmasks, I want to be easily able to obtain e.g. 255, #FF, "11111111" |
... and convert between those ... | |
ah, probably enbase/base #{FF} 2 ..... I just wrongly tried with #FF ..... but then each char got converted separately ... | |
I also found Sunanda's 'base-convert.r script, so forget my question .... | |
Gregg 13-Jan-2006 [3181] | From RAMBO group: I don't know about "pretty " versus loadable, but what specific issue does it cause that you don't want that extra information available? WRT "form 1.0" |
Luca 22-Jan-2006 [3182] | I need to "filter" the content of an object. Any better idea on how to do it other the this one: obj: make object! [ bb: 1 cc: 4 dd: 7 ] block: [bb dd] filter: func [obj block /local newobj][ newobj: make object! [] foreach [s v] third obj [ if find block to-word s [ newobj: make newobj reduce [ s v ] ] ] newobj ] probe filter obj block Result: make object! [ bb: 1 dd: 7 ] |
Gregg 22-Jan-2006 [3183] | Here's something I did that may work for you: obj-spec: func [ "Returns the object spec as a single line (flat) string." obj [object!] /only "no surrounding brackets" /mold "Multi-line MOLDed format" /local res ][ res: copy find/tail system/words/mold obj "make object! " if not mold [trim/lines res] if only [res: trim/auto next head remove back tail next res] res ] remove-words: func [ "Returns a copy of the object with the specified words removed." object [object!] words [word! block!] "The word, or words, to remove" /local spec ][ spec: load obj-spec object foreach word compose [(words)] [ remove/part find spec to set-word! word 2 ] make object! spec ] The reason it doesn't use THIRD on the object is because of how words are returned. I use OBJ-SPEC to save object spec blocks to disk for the same reason. |
Henrik 22-Jan-2006 [3184x3] | if the solution gregg posts is better, use that, but: a: make object! [ bb: 1 cc: 4 dd: 7 ] block: [bb dd] make object! foreach word difference first a block [head remove remove find third a to-set-word word] |
nah, doesn't work | |
d: third a make object! foreach word next difference first a block [head remove remove find d to-set-word word] seems to work | |
Luca 22-Jan-2006 [3187] | Gregg: Thank you, you are right, I forgot the 'THIRD problem. In other scripts I used the following solution to bypass it. 'prefs is an object containing various data types. 'rp2pcprefs is the file to save it to save-prefs: func [/local prefstmp][ prefstmp: copy/deep [] foreach w next first prefs [ append prefstmp reduce [to-word w get in prefs to-word w] ] save rp2pcprefs prefstmp ] load-prefs: func [/local prefstmp][ prefstmp: make object! [] if exists? rp2pcprefs [ foreach [w v] load rp2pcprefs [ prefstmp: make prefstmp reduce [to-set-word w ""] set in prefstmp to-word w v ] ] prefstmp ] Henrik: 'difference is a good point I didn't think to, then I like the one-liner :), thank you. |
Henrik 22-Jan-2006 [3188] | luca, check for stability and binding though. there are always a few holes, when messing with objects like that :-) |
older newer | first last |