Hi,
Warning! This post not suitable for KISS fans.
I can even say something Pro the SMC (Self Modifying Code)
See this: (a part of my %curry.r)
curry: func ["Create curried functions"
f [any-function!] "Function to be curried"
args [integer!] "Number of the arguments of the result"
] [
func map :toarg enum 1 args ao [
apply func [f args] [
function map :toarg enum args + 1 nargs :f [y] ao [
apply function [f args redargs] [redrest] [
redrest: reduce bind map :tga enum args + 1 nargs :f 'y
apply :f ac redargs redrest
]
] reduce [:f :args reduce bind map :tga enum 1 args 'a1]
]
] reduce [:f :args]
]
>From the conservative point of view it is a SMC, because it surely creates a
new function - i.e. a new code, unknown exactly during reading.
But if we just need the above source code not to be modified, it's
fulfilled. Moreover, the returned function is non-SMC either. (in the same
sense)
>From what I said it may be clear, that I don't like a code that modifies
itself (true SMC?) but I'v got nothing against a generic code - a code that
creates another code.
Ladislav
> When self modifying code goes wrong....
>
> ....It can go very, very, very, wrong!
>
> Imagine writing junk instrctions all the way through your code....
>
> The only place I've seen it used is in assembly language situations, where
> the speed matters.
>
> Mind you using REBOLs catch, throw, try commands could make the process a
> lot safer than it normally is. And with REBOLs rather wonderful ability to
> intermix code and data, you will probably start writing complex data
> structures that modify themselves according to their contents. ( Rather
than
> modifying the underlying program that uses the data structure...)
>
> Rob Lancaster
>
>