* table assignment in the context lua code
@ 2011-03-09 14:41 Ulrike Fischer
2011-03-09 15:10 ` Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: Ulrike Fischer @ 2011-03-09 14:41 UTC (permalink / raw)
To: ntg-context
font-dum.lua contains the following code snippet:
local reencodings = { }
fonts.enc.reencodings = reencodings
local function specialreencode(tfmdata,value)
local encoding = value and reencodings[value]
....
end
1. Why is the assignment
fonts.enc.reencodings = reencodings
and not the other way round?
Similar definitions in the same file use more "logical" looking
assignments like e.g. "local setups = fonts.protrusions.setups"
2. How does it work? Why is the local table variable "reencodings"
in the function specialreencode able to retrieve values stored later
in fonts.enc.reencodings?
--
Ulrike Fischer
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: table assignment in the context lua code
2011-03-09 14:41 table assignment in the context lua code Ulrike Fischer
@ 2011-03-09 15:10 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2011-03-09 15:10 UTC (permalink / raw)
To: news3, mailing list for ConTeXt users
On 9-3-2011 3:41, Ulrike Fischer wrote:
>
> font-dum.lua contains the following code snippet:
>
> local reencodings = { }
> fonts.enc.reencodings = reencodings
>
> local function specialreencode(tfmdata,value)
> local encoding = value and reencodings[value]
> ....
> end
>
>
>
> 1. Why is the assignment
> fonts.enc.reencodings = reencodings
> and not the other way round?
because it saves a lookup but the reverse works equally well, so
consider it a matter of taste
> Similar definitions in the same file use more "logical" looking
> assignments like e.g. "local setups = fonts.protrusions.setups"
>
>
> 2. How does it work? Why is the local table variable "reencodings"
> in the function specialreencode able to retrieve values stored later
> in fonts.enc.reencodings?
because we're talking pointers so in
t = { }
a = t
an assignment to a is also an assignment to t
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-09 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-09 14:41 table assignment in the context lua code Ulrike Fischer
2011-03-09 15:10 ` Hans Hagen
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).