| Store | Cart

Re: [TCLCORE] There is no justification for modifying [proc] for named parameters

From: Alexandre Ferrieux <alex...@gmail.com>
Sun, 21 May 2017 15:06:09 +0200
Hi Mathieu,

On Sun, May 21, 2017 at 1:27 PM, Mathieu Lafon <mla...@gmail.com> wrote:
>> % proc log {>   {level -name level -switch {{debug 0} {error 3}} -default 1}>   {time -name {time timestamp}}>   {message} } {>     if {![info exists time]} {set time [clock seconds]}>     array set levels {0 DEBUG 1 INFO 2 WARN 3 ERROR}>     puts "[clock format $time] : $levels($level) : $message"> }>> % log -level 2 "Warning..."> Sun Apr 23 20:29:41 UTC 2017 : WARN : Warning...> % log -timestamp 946684800 -debug -- -Y2K-> Sat Jan 01 00:00:00 UTC 2000 : DEBUG : -Y2K->> What will it look like with [eatargs]?> - How are local variables defined? Will they be created by [eatargs] at runtime?> - How are defined the named arguments? Is it a parameter of [eatargs]> or are they defined elsewhere?

Here's how I would [eatargs] it :-)

  proc log args  {
     eatargs {{level -name level -switch {{debug 0} {error 3}} -default 1}
                  {time -name {time timestamp}}
                  {message} }
     ...
  }

The variables can be thought of as populated by [eatargs] at runtime,
though the CompileProc of [eatargs] will prepare their slots in the
LVT.

-Alex

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
Colin McCormack May 20, 2017 03:11 am
Mathieu Lafon May 20, 2017 08:38 am
Colin McCormack May 20, 2017 08:53 am
Colin McCormack May 20, 2017 08:58 am
Mathieu Lafon May 20, 2017 10:09 am
Colin McCormack May 20, 2017 10:15 am
Colin McCormack May 20, 2017 10:16 am
Colin McCormack May 20, 2017 10:23 am
Mathieu Lafon May 20, 2017 10:31 am
Colin McCormack May 20, 2017 10:41 am
Colin McCormack May 20, 2017 10:54 am
Colin McCormack May 20, 2017 10:54 am
Mathieu Lafon May 20, 2017 02:06 pm
Colin McCormack May 20, 2017 02:53 pm
Alexandre Ferrieux May 21, 2017 12:01 am
Colin McCormack May 21, 2017 01:16 am
Colin McCormack May 21, 2017 02:04 am
Mathieu Lafon May 21, 2017 11:27 am
Alexandre Ferrieux May 21, 2017 01:06 pm
Kevin Kenny May 20, 2017 02:01 pm
Colin McCormack May 20, 2017 02:39 pm
Colin McCormack May 20, 2017 11:58 pm
Alexandre Ferrieux May 20, 2017 09:12 am
Colin McCormack May 20, 2017 09:45 am
Peter da Silva May 22, 2017 11:42 am
Colin McCormack May 22, 2017 12:05 pm
Messages in this thread