World: r3wp
[Core] Discuss core issues
older newer | first last |
Volker 27-Dec-2005 [3032x3] | I patched it a bit to be more verbose: http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=volkswebserv.r But that one has bugs after a few calls. Don't know about webserv.r itself, i guess it is more stable. |
protecting system/locale: if user cant run code, user cant change it. if user can run code, he does not need to change those strings. | |
(my volkswebserv.r is for debugging, to show errors and such in console. So i can live with that instability. | |
Gabriele 28-Dec-2005 [3035] | if REBOL 3 is going to support modules, then it will provide the kind of security requested by Petr. |
Pekr 28-Dec-2005 [3036] | well, I believe that rebol 3 will actually support modules, as it will be kind of main product release, which can afford new ideas here or there and new incompatibilities here or there, if done for good. The only question is of course the timing - Rebol 3 in two years? :-) |
JaimeVargas 29-Dec-2005 [3037x2] | Any one interested in getting this ? >> printf ["%10.2E %s" to decimal! 1000 "dinar"] 1.00E+03 dinar >> sprintf ["%10.2E %s" to decimal! 1000 "dinar"] == " 1.00E+03 dinar" |
It is an actual wrap of the C printf routines. | |
Graham 29-Dec-2005 [3039] | Lots of people have asked for a printf in the past. |
JaimeVargas 29-Dec-2005 [3040x4] | Here it is consider it why-wire's team new years gift. team: [cyphre ladislav jaime] |
Rebol [] comment [ ; example usage: kernel: load/library %kernel32.dll routine-call kernel "MulDiv" [int] [3 [integer!] 2 [integer!] 1 [integer!]] ; == 6 ] routine-call: func [ library [library!] routine-name [string!] return-spec [block!] arguments [block!] /typed {Arguments is block structure is: [argument-value [datatype] ...]} /local routine spec call argument type typed-rule ] [ spec: make block! length? arguments call: make block! (length? arguments) / 2 + 1 insert call [return routine] typed-rule: copy [] if typed [typed-rule: [set type skip]] parse reduce arguments [ any [ set argument skip typed-rule ( insert/only tail spec 'argument insert/only tail spec either typed [ type ][ reduce [type?/word get/any 'argument] ] insert/only tail call get/any 'argument ) ] ] insert tail spec [return:] insert/only tail spec return-spec routine: make routine! spec library routine-name do call ] use [libc zero-char as-rebol-string malloc][ libc: load/library %/usr/lib/libc.dylib ; osx variable zero-char: #"^@" as-rebol-string: func [ [catch] s [string!] /local pos ][ unless pos: find s zero-char [throw make error! "s is not a c-string"] s: head remove/part pos tail s replace/all s "\n" newline replace/all s "\t" tab ] malloc: func [ size [integer!] "size in bytes" ][ head insert/dup copy {} zero-char size ] sprintf: func [ spec {block structure is: [format values ...]} /local s ][ s: malloc 4096 insert/only head spec 's routine-call libc "sprintf" [int] spec as-rebol-string s ] printf: func [ spec {block structure is: [format values ...]} ][ print sprintf spec ] ] | |
You need to change the location of your libc. The code above is hard coded for OSX. | |
Now is possible to pretty print things with short code ;-) >> repeat i 3 [printf reduce ["%2d-station%s" i either i > 1 ["s"][""]]] 1-station 2-stations 3-stations | |
Volker 29-Dec-2005 [3044] | 1) (paranoid): how do you handle buffer-overruns? 2) I could make a little script which takes the format string and explains it. If you get this into rebol :) |
JaimeVargas 29-Dec-2005 [3045x3] | 1) Buffer overruns seem to be protected by the GC. I try over run a very small buffer and I was uncessful. |
2) That will be nice. | |
The work above was mostly ladislave on the call-routine and the rest is mine. I will probably post it to rebol.org after a few changes and additions to make it work in all platforms. Maybe Carl will like to include it by default in rebol. | |
Graham 29-Dec-2005 [3048x2] | set object none ; sets all the members of an object to none set object [ "first" ] ; sets the first member of the object to "first" how to set another member of the object only knowing the name of the member ? Is there a quick way? |
no matter. | |
BrianH 29-Dec-2005 [3050] | ; Try this object/member: value ; or this set in object 'member value |
Graham 29-Dec-2005 [3051] | thanks .. set in object 'member value is what I was looking for . |
BrianH 29-Dec-2005 [3052] | Yeah, IN can speed things up a bit when repeatedly accessing the same member of a object, saving on lookup time. It can be used to provide object field access in rebcode by calling it with apply too. Useful function. |
Pekr 30-Dec-2005 [3053] | Jaime - we have request for printf or similar functionality on ml - maybe you could help the newbie? |
JaimeVargas 30-Dec-2005 [3054] | Pekr. I don't understand what you want here? Do you want me to post the printf code to the ML? |
Pekr 30-Dec-2005 [3055] | yes, there is conicidentally newbie's post asking for some formatting functions ... there is some discussion already, Ladislav participated too .... |
JaimeVargas 30-Dec-2005 [3056] | Aha. I have not being in the ML for ages. |
Pekr 30-Dec-2005 [3057] | :-) do you suffer "altme syndrome"? :-) |
JaimeVargas 30-Dec-2005 [3058] | I think so. Besides some how the ML software kick-me out in one of the upgrades, so I didn't bother to register again. |
Louis 2-Jan-2006 [3059] | Does anyone know when rebol will support unicode? |
Henrik 3-Jan-2006 [3060] | Interesting... I thought percent! would be a legal datatype in REBOL, since we have so many other common types. Wonder why it's left out? |
Sunanda 3-Jan-2006 [3061] | Extensive discussion on the merits and demerits of percent! here: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlZXTJ |
Henrik 3-Jan-2006 [3062] | amazing, it seems I even responded to that thread :-) |
Graham 3-Jan-2006 [3063x2] | That's probably why you thought there was a percent! datatype! |
but what we need is custom datatypes | |
Henrik 3-Jan-2006 [3065x2] | graham, the fact that it isn't there, kinda ruins my idea for implementing percent based widths in LIST-VIEW so that it's easy to discern between integers and percentages such as [50% 30%]. That's not so easy now, unless I do it the hokey way and use issue! or some other type to describe percent. |
I guess I'll have to save it for later | |
Graham 3-Jan-2006 [3067] | Ashley uses decimals. |
JaimeVargas 4-Jan-2006 [3068x5] | Rebol doesn't stop to amaze me. Here is some pretty neat magic to make instances of classes with protected variables. |
CounterClass: context [ c: 0 bump: does [c: c + 1] read: does [c] bump-by: func [inc][c: c + inc] ] make-instance: func [ class /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)] ] ] ctr1: make-instance CounterClass crt2: make-instance CounterClass ctr1/bump ctr1/bump ctr1/read ctr2/bump ctr2/read | |
Both ctr1 and ctr2 have private state that can only be access through the defined interface. | |
Only issue with this is that it can not handle refinements or local func vars yet. local func vars should be easy. Refinements is a challenge. | |
BTW. Both ctr1 and ctr2 share the funcs defined in the CounterClass. With standard objects you don't need all this trickery but you receive a copy of the funcs. | |
Anton 4-Jan-2006 [3073] | Henrik, better to use "weights" (decimals) rather than percentages, for the user of your style, anyway. |
Henrik 5-Jan-2006 [3074x2] | anton, thanks, that's a good idea. |
>> to-word "a b" == a b >> to-set-word "a b" == a b: Why is that legal? | |
Ladislav 5-Jan-2006 [3076x3] | I think, that the correct answer is: "why not?" |
another example: type? to word! "a:" | |
or to word! "1" | |
Geomol 6-Jan-2006 [3079] | Jaime, that's a pretty neat trick with the classes. Actually it's an extension of the language with some feature, that is not initially possible. I'll use some time this week-end to make a deeper inspection of the code. Are you the author? |
Pekr 6-Jan-2006 [3080x2] | struggling with lowering security in my script - how to lower it in my script?? I don't want to answer the question if rebol should lower it ... |
a bug? to-rebol-file to-local-file %/C/Rebol/ == %/C/Rebol Why it removes trailing slash? Then if you submit it to load it fails .... | |
older newer | first last |