From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/57600 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: arguments to ctxlua Date: Tue, 30 Mar 2010 19:52:54 +0200 Message-ID: <4BB23A76.2030704@wxs.nl> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1269971600 21049 80.91.229.12 (30 Mar 2010 17:53:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 30 Mar 2010 17:53:20 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Mar 30 19:53:14 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nwfcm-0002A0-JR for gctc-ntg-context-518@m.gmane.org; Tue, 30 Mar 2010 19:53:12 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8D42AC9D9E; Tue, 30 Mar 2010 19:53:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gng0kd88rbVW; Tue, 30 Mar 2010 19:53:08 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 83C43C9D9F; Tue, 30 Mar 2010 19:53:08 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E0120C9D9F for ; Tue, 30 Mar 2010 19:53:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id F+Sa8ckWHyb3 for ; Tue, 30 Mar 2010 19:53:04 +0200 (CEST) Original-Received: from mail.solcon.nl (unknown [217.121.8.199]) by balder.ntg.nl (Postfix) with ESMTP id BA434C9D9E for ; Tue, 30 Mar 2010 19:53:04 +0200 (CEST) X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by controller-9 (SurgeMail 4.2d2) with ESMTP id 7794-1713362 for multiple; Tue, 30 Mar 2010 19:51:51 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3 In-Reply-To: X-Authenticated-User: hagen@controller-9 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:57600 Archived-At: On 30-3-2010 19:45, Hans van der Meer wrote: > When I have a Lua function with 2 arguments: > \startluacode > function f(a,b) > ... > \stopluacode > > called through: > \def\callf#1#2{\ctxlua{f("#1","#2")}} > > and do this actually with one argument: > \callf{one} so, #1 will be one and #2 will be the next token (whatever that is) > then I find that the absent argument b in f(a,b) is not nil but a string > of length 1. > > That is a bit of a nuisance because I would like to use the Lua idiom: > function f(a,b) > local b = b or default > but that is frustrated by the behaviour shown. > > Is this an artifact of either luatex or ConTeXt? Can it be avoided such > that in this case b will be nil? just tex but in any case even if #2 is empty you need to test like this local b = b ~= "" and b or default watch the order ... we want b to be set to b when not empty Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________