Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-04-23
06:00 • Closed ticket [939190ffff]: TIP #187:lambda plus 7 other changes artifact: 33c192cc56 user: msofer
2004-04-22
05:46 • Add attachment lambda2.patch to ticket [939190ffff] artifact: 67c0372bb2 user: msofer
05:46 • Ticket [939190ffff] TIP #187:lambda status still Open with 4 other changes artifact: 43998f4fd0 user: msofer
05:17 • Ticket [939190ffff]: 4 changes artifact: fbcd14069f user: msofer
04:55 • Ticket [939190ffff]: 4 changes artifact: 461a6ea7fb user: msofer
02:16 • Ticket [939190ffff]: 4 changes artifact: 4e346327c3 user: msofer
02:09 • Ticket [939190ffff]: 4 changes artifact: 463a4ade80 user: msofer
02:09 • Add attachment lambda.patch to ticket [939190ffff] artifact: b5c506867c user: msofer
00:45 • Ticket [939190ffff] TIP #187:lambda status still Open with 4 other changes artifact: 3bb650e562 user: msofer
2004-04-21
17:17 • Ticket [939190ffff]: 4 changes artifact: 68d3b49a39 user: msofer
16:52 • Ticket [939190ffff]: 4 changes artifact: 45e72f0bf7 user: msofer
09:52 • New ticket [939190ffff]. artifact: 31b4988dc6 user: msofer

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: