Version 0 of If we had no proc

Updated 2007-09-28 14:48:37 by suchenwi

Richard Suchenwirth 2007-09-28 - Since Tcl 8.5 gives us the apply command, it is possible to remodel part (or even all?) of the proc functionality in its terms, in a devilish cascade of interp alias and apply:

 interp alias {} proc {} \
    apply {{name argl body} {interp alias {} $name {} apply [list $argl $body]}}

We define an alias named proc, which overrides the built-in command, to apply to a {name argl body} triplet a codelet that defines an alias name to apply to the argl the body. Whew...

Testing (should print 49, did for me):

 proc square x {expr {$x**2}}
 puts [square 7]

Category Example