Ticket UUID: | 939190 | |||
Title: | TIP #187:lambda | |||
Type: | Patch | Version: | None | |
Submitter: | msofer | Created on: | 2004-04-21 09:52:52 | |
Subsystem: | None | Assigned To: | msofer | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2004-04-23 06:00:54 | |
Resolution: | Out of Date | Closed By: | msofer | |
Closed on: | 2004-04-22 23:00:54 | |||
Description: |
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 | |||
User Comments: |
msofer added on 2004-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 msofer added on 2004-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:: msofer added on 2004-04-22 05:17:54: File Deleted - 84588: File Added - 84592: lambda2.patch msofer added on 2004-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. msofer added on 2004-04-22 02:16:37: File Deleted - 84496: msofer added on 2004-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. msofer added on 2004-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 msofer added on 2004-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. msofer added on 2004-04-21 16:52:52: File Added - 84494: lambda.patch |