From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/74151 Path: news.gmane.org!not-for-mail From: Mathieu Dupont Newsgroups: gmane.comp.tex.context Subject: LuaTeX Function Arguments Variables Parameters List ConTeXt Lua \startluacode Date: Fri, 27 Jan 2012 19:06:48 -0500 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1608137382==" X-Trace: dough.gmane.org 1327709239 20290 80.91.229.12 (28 Jan 2012 00:07:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 28 Jan 2012 00:07:19 +0000 (UTC) To: ConTeXt Original-X-From: ntg-context-bounces@ntg.nl Sat Jan 28 01:07:12 2012 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 1Rqvp2-0001mP-C6 for gctc-ntg-context-518@m.gmane.org; Sat, 28 Jan 2012 01:07:12 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 620A9CB20B; Sat, 28 Jan 2012 01:07:10 +0100 (CET) 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 n7WF9S4rNfBU; Sat, 28 Jan 2012 01:07:07 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C2F97CB203; Sat, 28 Jan 2012 01:07:06 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6049DCB203 for ; Sat, 28 Jan 2012 01:07:05 +0100 (CET) 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 mDuhZg07KZZ4 for ; Sat, 28 Jan 2012 01:06:53 +0100 (CET) Original-Received: from filter2-nij.mf.surf.net (filter2-nij.mf.surf.net [195.169.124.153]) by balder.ntg.nl (Postfix) with ESMTP id BDBEECB201 for ; Sat, 28 Jan 2012 01:06:53 +0100 (CET) Original-Received: from col0-omc2-s9.col0.hotmail.com (col0-omc2-s9.col0.hotmail.com [65.55.34.83]) by filter2-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q0S06pbN015690 for ; Sat, 28 Jan 2012 01:06:52 +0100 Original-Received: from COL107-W30 ([65.55.34.72]) by col0-omc2-s9.col0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 27 Jan 2012 16:06:48 -0800 X-Originating-IP: [173.179.168.162] Importance: Normal In-Reply-To: X-OriginalArrivalTime: 28 Jan 2012 00:06:48.0244 (UTC) FILETIME=[BA77D740:01CCDD50] X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=65.55.34.83; country=US; region=WA; city=Redmond; postalcode=98052; latitude=47.6801; longitude=-122.1206; metrocode=819; areacode=425; http://maps.google.com/maps?q=47.6801,-122.1206&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0aGqM6QKn - d1e960d476d3 - 20120128 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.153 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:74151 Archived-At: --===============1608137382== Content-Type: multipart/alternative; boundary="_cc8a66f4-0c8b-4d9d-859f-ea14e253b03d_" --_cc8a66f4-0c8b-4d9d-859f-ea14e253b03d_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi List=2C I am trying to program with Lua but there are concepts I must not understan= d=2C and the documentation is somewhat lacking. The only useful thing I could use is Hans' manual=2C thanks to him. If someone could help me just understanding the concept I must me missing i= n this simple example I would appreciate it. So here it is. Running the following code=2C variable "a" should not be modified by my fun= ction=2C and stay (1=2C2)=2C but it does get modified and becomes (4=2C2) l= ike the new variable "b" I am creating. What is wrong with my code ? Thank you for any hint ! Mathieu \starttext \startluacode function myFunc(arg) local var =3D arg var[1] =3D var[1] + 3 return var end local a =3D {1=2C2} context("a =3D \\{") context(a[1]) context("=2C\\=3B") context(a[2]) context("\\}\\par") context("\\blank") local b =3D myFunc(a) context("a =3D \\{") context(a[1]) context("=2C\\=3B") context(a[2]) context("\\}\\par") context("\\blank") context("b =3D \\{") context(b[1]) context("=2C\\=3B") context(b[2]) context("\\}\\par") \stopluacode \stoptext = --_cc8a66f4-0c8b-4d9d-859f-ea14e253b03d_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi List=2C

I am trying to pro= gram with Lua but there are concepts I must not understand=2C and the docum= entation is somewhat lacking.

The only useful thing I could use is = Hans' manual=2C thanks to him.

<= /font>
If someone could help me just unders= tanding the concept I must me missing in this simple example I would apprec= iate it.

So here it is.

=
Running the following code=2C varia= ble "a" should not be modified by my function=2C and stay (1=2C2)=2C but it= does get modified and becomes (4=2C2) like the new variable "b" I am creat= ing.

What is wrong with my code ?

Thank you for any hint !<= /font>

Mathieu


\s= tarttext


\startluacode

function myFunc(arg)

<= span class=3D"ecxApple-tab-span" style=3D"white-space:pre"> local va= r =3D arg

var[1] =3D var[1] + 3

return= var

end


l= ocal a =3D {1=2C2}


context("a =3D \= \{")

context(a[1])

contex= t("=2C\\=3B")

context(a[2])

context("\\}\\par")

context("\\blank")


local b =3D myFunc(a)

<= div>
context("a =3D \\{")

context(a[= 1])

context("=2C\\=3B")

c= ontext(a[2])

context("\\}\\par")

context("\\blank")


context(= "b =3D \\{")

context(b[1])

context("=2C\\=3B")

context(b[2])

=
context("\\}\\par")


\sto= pluacode


\stoptext






= --_cc8a66f4-0c8b-4d9d-859f-ea14e253b03d_-- --===============1608137382== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1608137382==--