Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] rebol weak points (i think) Re:(6)

From: agem:crosswinds at: 11-Sep-2000 22:17

[g--santilli--tiscalinet--it] wrote on 11-Sep-2000/19:04:09+2:00
> Hello [chris--double--tab--co--nz]! > > On 11-Set-00, you wrote: > > c>> Try compiling this: > c>> > c>> do ask "Please enter some Rebol code: " > > c> FORTH and Lisp systems don't seem to have a problem with this. > c> Most Common Lisp systems I know are compiled and have > c> interactive input. See Corman Lisp for an example > c> (http://www.corman.net). Generally the compiler is part of the > c> run time and compiles the entered code on the fly. > > So you want all of your script be compiled in a 400k executable? >
Compiling the compiler into the runtime? Compilers can be small..
> Anyway, that is not the problem. Let me know if you are able to > compile the following code snippets: > > my-print: print-odd: func [a] [ > print [a "is odd."] > my-print: :print-even > ] > print-even: func [a] [ > print [a "is even."] > my-print: :print-odd > ] > repeat i 5 [my-print i] > > 1 is odd. > 2 is even. > 3 is odd. > 4 is even. > 5 is odd. >
Wheres the problem? yes, by default you have to lookup each call in a table. for speed, to inline the primitives, there is a need for hotspot-style compilers. or marking never-changing code by hand ("compile func"). (like a stronger [protect 'if] which can't be removed (in the module)). problems arise if you do a: func[a b][] ; 2 args user: func[][ a 1 2 ] a: func[a][] ; 1 arg user do you?
> --- > > ; this is just an example... > amiga: make object! [ > send-to-par: func [something] [write/binary %/par something] > play-sound: func [sample-data] [write/binary %/audio sample-data] > ] > unix: make object! [ > send-to-par: func [something] [write/binary %/dev/lp0 something] > play-sound: func [sample-data] [write/binary %/dev/dsp sample-data] > ] > others: make object! [ > send-to-par: func [val] [] > play-sound: func [val] [] > ] > > code: [ > send-to-par some-data-for-the-printer > play-sound hello-sample > play-sound goodbye-sample > ] > > current-system: get pick [ > ; going by memory, the actual table might be different... > amiga > others > others > unix > ; etc. > ] system/version/4 > > bind code in current-system 'self > do code >
if bind is allways bind/copy this works. note we have early binding in rebol, which gives very good hints what will be called (can be reduced to indirect addresses IMO). Compiler has to insert calls beetween the addresses, yes.
> --- > > ; self modifying code
i know SM-code is possible, but is it usefull? maybe usefull if rebol could access its callers pc. do you know of some use? which can not be reduced to some parts, allowing for something like "compile func" for others? if you know, can we apply a forthish way? : make a block-entry big enough for some usefull code, like add, if, .. and of course indirect call . if you bind to a froozen primitive, copy its code, else insert a call. if you store to a speed-block! , its more costly, and you have to fight with code/data-cache-sync. with fixed block-size one has to insert some nops too. but modern prefetchers may like this way more than interpreter-jumps?
> code: [ > ; initialization, needs to be run the first time only > random/seed now > remove/part code 5 > print random 10 > ] > print mold code > loop 5 code > print mold code > > >> print mold code > [ > random/seed now > remove/part code 5 > print random 10 > ] > >> loop 5 code > 5 > 6 > 6 > 3 > 7 > >> print mold code > [ > print random 10 > ] >
i think this would be hard: caller: func[][my-dialect these are dialect-words!] my-dialect: func[][ parse-caller[dialect stuff] ] but it does not exists.. and finding the 'b in a/b very quick, as long as there is no type-system with fixed offsets. But, there is rebol/command with some typing stuff. Carl in front of his C compiler: Can't be long until he thinks that job can be done by Rebol too. if he changes the language a bit.. If he localizes the restrictions.. Components, Modules, we can't change them too.. Speed by simplification - he has done it before..
> Regards, > Gabriele. > -- > Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer > Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/ >
Volker