ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mathieu Dupont <mathieudupont@hotmail.com>
To: ConTeXt <ntg-context@ntg.nl>
Subject: LuaTeX Function Arguments Variables Parameters List ConTeXt Lua \startluacode
Date: Fri, 27 Jan 2012 19:06:48 -0500	[thread overview]
Message-ID: <COL107-W303DA2C39276D4E046CEF1B28F0@phx.gbl> (raw)
In-Reply-To: <COL107-W487CDE8763FF99FDA17729B28F0@phx.gbl>


[-- Attachment #1.1: Type: text/plain, Size: 1112 bytes --]


Hi List,
I am trying to program with Lua but there are concepts I must not understand, and the documentation is somewhat lacking.
The only useful thing I could use is Hans' manual, thanks to him.
If someone could help me just understanding the concept I must me missing in this simple example I would appreciate it.
So here it is.
Running the following code, variable "a" should not be modified by my function, and stay (1,2), but it does get modified and becomes (4,2) like 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 = arg
	var[1] = var[1] + 3
	return var
end

local a = {1,2}

context("a = \\{")
context(a[1])
context(",\\;")
context(a[2])
context("\\}\\par")
context("\\blank")

local b = myFunc(a)

context("a = \\{")
context(a[1])
context(",\\;")
context(a[2])
context("\\}\\par")
context("\\blank")

context("b = \\{")
context(b[1])
context(",\\;")
context(b[2])
context("\\}\\par")

\stopluacode

\stoptext





 		 	   		   		 	   		  

[-- Attachment #1.2: Type: text/html, Size: 3085 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

       reply	other threads:[~2012-01-28  0:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <COL107-W487CDE8763FF99FDA17729B28F0@phx.gbl>
2012-01-28  0:06 ` Mathieu Dupont [this message]
2012-01-28  0:39   ` Philipp Gesang
2012-01-28  3:01   ` Mathieu Dupont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=COL107-W303DA2C39276D4E046CEF1B28F0@phx.gbl \
    --to=mathieudupont@hotmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).