TIP #187:lambda
Closed / Out of Date939190ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-04-21 09:52:52
The enclosed patch provides an implementation of TIP
#187, slightly modified. It creates a new command
[lambda], so that
% set p [lambda x {string length $x}]
::tcl::lambda::{x {string length $x}}
% info proc tcl::lambda::*
::tcl::lambda::Create {::tcl::lambda::{x {string
length $x}}}
% $p 1 2
wrong # args: should be "::tcl::lambda::{x {string
length $x}} x"
% $p bgiul
5
% append p " "
::tcl::lambda::{x {string length $x}}
% info proc tcl::lambda::*
::tcl::lambda::Create
% $p hvjh
4
% info proc tcl::lambda::*
::tcl::lambda::Create {::tcl::lambda::{x {string
length $x}} }
% info body $p
string length $x
Note that the lambda expressions auto cleanup on
shimmering (when " " was appended), but are otherwise
plain procs.
The enclosed patch creates the [lambda] as a builtin;
it is also possible to only patch tclObj.c and provide
the functionality as a C-extension; alternatively, one
could also patch only the .c files, and provide the
functionality via a pure tcl extension instead of
patching init.tcl
msoferplain2004-04-21 16:52:52
File Added - 84494: lambda.patch
msoferplain2004-04-21 17:17:28
File Deleted - 84494: File Added - 84496: lambda.patch Logged In: YES user_id=148712 Patch updated, with slightly clearer code.
msoferplain2004-04-22 00:45:24
Logged In: YES user_id=148712 Boo ... bad proc names, review needed! % $p hgg 3 % eval $p jhg extra characters after close-brace
msoferplain2004-04-22 02:09:21
File Added - 84566: lambda.patch
Logged In: YES
user_id=148712
Can't do much about spaces in the name - except proposing
safety in eval'ing ...
Updated patch, follows the TIP more closely. Now we have
% set p [lambda x {string length $x}]
::tcl::lambda x {string length $x}
ie, $p's string rep is [list ::tcl::lambda $argList $body]
::tcl::lambda::Create and the modifs to ::unknown are meant
to recreate a lambda expression from its string
representation, to recover from a possible shimmering; they
may not be robust enough for other uses.
This is a non-standard hacky way to satisfy the "every value
is a string" requisite; not sure how much I like it.
msoferplain2004-04-22 02:16:37
File Deleted - 84496:
msoferplain2004-04-22 04:55:57
File Added - 84588: lambda2.patch Logged In: YES user_id=148712 new lambda2.patch: does not use ptr2 in the cmdNameType obj, as some extensions use it for their own purposes. It is now the Command struct itself that knows it should autocleanup, no changes to any public structures.
msoferplain2004-04-22 05:17:54
File Deleted - 84588: File Added - 84592: lambda2.patch
msoferplain2004-04-22 05:46:02
File Deleted - 84592: File Added - 84595: lambda2.patch Logged In: YES user_id=148712 updated patch, some stuff goes under ::tcl::unsupported::
msoferplain2004-04-23 06:00:54
Logged In: YES user_id=148712 This has been superseeded by Patch #940207 https://sourceforge.net/tracker/index.php?func=detail&aid=940207&group_id=10894&atid=310894
Log in (anonymous is fine) to add a comment.
Attachments:
- lambda2.patch [download] added by msofer on 2004-04-22 05:46:02. [details]
- lambda.patch [download] added by msofer on 2004-04-22 02:09:21. [details]