[REBOL] rebol weak points (i think) Re:(6)
From: chris:double:tab at: 12-Sep-2000 9:28
>So you want all of your script be compiled in a 400k executable?
No, I was just making the point that it seemed to be possible to compile REBOL,
not that it was a necessity. As an aside, Corman Common Lisp for Win32, the
console application (equivalent to Rebol/Core I guess) is a 600K executable. But
then it doesn't include the source as part of the executable, or the networking,
etc, etc.
>Anyway, that is not the problem. Let me know if you are able to
>compile the following code snippets:
Are you asking if it is possible to compile the code snippet you give in any
language or in Rebol? If any language, the following works fine in a compiled
Lisp and I can't imagine why the same wouldn't work in a compiled REBOL either:
(defun print-odd (a)
(format t "~A is odd.~%" a)
(setf (symbol-function 'my-print) #'print-even))
(defun print-even (a)
(format t "~A is even.~%" a)
(setf (symbol-function 'my-print) #'print-odd))
(setf (symbol-function 'my-print) #'print-odd)
(loop for i from 1 to 5 do (my-print i))
Gives:
1 is odd.
2 is even.
3 is odd.
4 is even.
5 is odd.
Your other example, the amiga, unix, etc objects and binding the methods to the
code is quite neat. This could be compiled where 'do' is the equivalent to other
languages 'eval'. In a compiled language with 'eval', the 'eval' can either
interpret the results or wrap the eval into an anonymous function, compile that
function and then execute it. So the following would be the equivalent to
implementing an eval:
(eval '(do-something))
=> becomes (funcall (compile (lambda () (do-something))))
The result of that compilation is executed. Obviously speed of compilation
becomes an issue.
Self modifying code as in your next example becomes a tad more difficult to
compile :-). I wouldn't know how to do it myself without changing the code to
use some sort of 'eval' type of thing.
Personally REBOL is fast enough to do the sorts of things I use it for anyway so
I don't have a problem with it being compiled or not compiled. It amazes me that
something like REBOL/View can fit into such a small package!
Cheers,
Chris.
--
http://www.double.co.nz/cl
http://www.double.co.nz/dylan