ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* search path for require(...)
@ 2011-03-24  9:50 Ulrike Fischer
  2011-03-24 10:14 ` Philipp Gesang
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrike Fischer @ 2011-03-24  9:50 UTC (permalink / raw)
  To: ntg-context

I'm trying to store the virtual lua chess fonts I'm currently
creating so that latex and context can use them. 

1. At first I stored the vf-chess-XX.lua in tex/luatex. This works
for latex but not for context. tex/generic works for both. 

2. My fonts loads a lua-file which should be shared by all fonts
with 

chessfss=require('chessfss')

latex finds the chessfss.lua without problems in various locations
(e.g. tex/generic) but context not. How can I solve this problem?



-- 
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] 5+ messages in thread

* Re: search path for require(...)
  2011-03-24  9:50 search path for require(...) Ulrike Fischer
@ 2011-03-24 10:14 ` Philipp Gesang
  2011-03-24 10:34   ` Ulrike Fischer
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Gesang @ 2011-03-24 10:14 UTC (permalink / raw)
  To: news3, mailing list for ConTeXt users


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


On 2011-03-24 <10:50:58>, Ulrike Fischer wrote:
> I'm trying to store the virtual lua chess fonts I'm currently
> creating so that latex and context can use them. 
> 
> 1. At first I stored the vf-chess-XX.lua in tex/luatex. This works
> for latex but not for context. tex/generic works for both. 
> 
> 2. My fonts loads a lua-file which should be shared by all fonts
> with 
> 
> chessfss=require('chessfss')
> 
> latex finds the chessfss.lua without problems in various locations
> (e.g. tex/generic) but context not. How can I solve this problem?

Hi Ulrike,

see also:
  http://www.ntg.nl/pipermail/ntg-context/2010/047721.html

(You’re going to have to declare the table “chessfss” globally
for this to work.)

Regards, Philipp

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: search path for require(...)
  2011-03-24 10:14 ` Philipp Gesang
@ 2011-03-24 10:34   ` Ulrike Fischer
  2011-03-24 10:50     ` Philipp Gesang
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrike Fischer @ 2011-03-24 10:34 UTC (permalink / raw)
  To: ntg-context

Am Thu, 24 Mar 2011 11:14:00 +0100 schrieb Philipp Gesang:

>> I'm trying to store the virtual lua chess fonts I'm currently
>> creating so that latex and context can use them. 
>> 
>> 1. At first I stored the vf-chess-XX.lua in tex/luatex. This works
>> for latex but not for context. tex/generic works for both. 
>> 
>> 2. My fonts loads a lua-file which should be shared by all fonts
>> with 
>> 
>> chessfss=require('chessfss')
>> 
>> latex finds the chessfss.lua without problems in various locations
>> (e.g. tex/generic) but context not. How can I solve this problem?
> 
> Hi Ulrike,
> 
> see also:
>   http://www.ntg.nl/pipermail/ntg-context/2010/047721.html

Ah. chessfss = require('chessfss.lua') works in context. And it
seems to work with latex too (I had somewhere in the back of my mind
the thought that the ".lua" extension breaks with latex but can't
reproduce it currently). 


> (You’re going to have to declare the table “chessfss” globally
> for this to work.)

The chessfss.lua has a "return Table" at the end which declares the
table chessfss. 

To quote from http://lua-users.org/wiki/LuaModuleFunctionCritiqued:

"The problems above can be avoided by not using the module function
but instead defining modules in the following simple way: [*1][*2] 

-- hello/world.lua
local M = {}

local function test(n) print(n) end
function M.test1() test(123) end
function M.test2() M.test1(); M.test1() end

return M

and importing modules this way: 

local MT = require "hello.world"
MT.test2()"


-- 
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] 5+ messages in thread

* Re: search path for require(...)
  2011-03-24 10:34   ` Ulrike Fischer
@ 2011-03-24 10:50     ` Philipp Gesang
  2011-03-24 11:41       ` Ulrike Fischer
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Gesang @ 2011-03-24 10:50 UTC (permalink / raw)
  To: news3, mailing list for ConTeXt users


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

On 2011-03-24 <11:34:21>, Ulrike Fischer wrote:
> Am Thu, 24 Mar 2011 11:14:00 +0100 schrieb Philipp Gesang:
> 
> >> I'm trying to store the virtual lua chess fonts I'm currently
> >> creating so that latex and context can use them. 
> >> 
> >> 1. At first I stored the vf-chess-XX.lua in tex/luatex. This works
> >> for latex but not for context. tex/generic works for both. 
> >> 
> >> 2. My fonts loads a lua-file which should be shared by all fonts
> >> with 
> >> 
> >> chessfss=require('chessfss')
> >> 
> >> latex finds the chessfss.lua without problems in various locations
> >> (e.g. tex/generic) but context not. How can I solve this problem?
> > 
> > Hi Ulrike,
> > 
> > see also:
> >   http://www.ntg.nl/pipermail/ntg-context/2010/047721.html
> 
> Ah. chessfss = require('chessfss.lua') works in context. And it
> seems to work with latex too (I had somewhere in the back of my mind
> the thought that the ".lua" extension breaks with latex but can't
> reproduce it currently). 
> 
> 
> > (You’re going to have to declare the table “chessfss” globally
> > for this to work.)
> 
> The chessfss.lua has a "return Table" at the end which declares the
> table chessfss. 
> 
> To quote from http://lua-users.org/wiki/LuaModuleFunctionCritiqued:
> 
> "The problems above can be avoided by not using the module function
> but instead defining modules in the following simple way: [*1][*2] 

Of course, that’s the Lua way. I can’t guess what you’re up to
but if it’s going to eventually become a module, the “chessfss”
table should not pollute the global namespace. There are
canonical locations (check luat-ini.lua) where the functions and
data should go:

  http://www.ntg.nl/pipermail/ntg-context/2010/054982.html

So you might be better off dropping “require” altogether and just
conclude your module with a line like:

  thirddata = thirddata or { }
  thirddata.chessfss = chessfss

instead of returning a table, then loading it with “loadluafile”.

Regards, Philipp

> 
> -- hello/world.lua
> local M = {}
> 
> local function test(n) print(n) end
> function M.test1() test(123) end
> function M.test2() M.test1(); M.test1() end
> 
> return M
> 
> and importing modules this way: 
> 
> local MT = require "hello.world"
> MT.test2()"
> 
> 
> -- 
> 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
> ___________________________________________________________________________________

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: search path for require(...)
  2011-03-24 10:50     ` Philipp Gesang
@ 2011-03-24 11:41       ` Ulrike Fischer
  0 siblings, 0 replies; 5+ messages in thread
From: Ulrike Fischer @ 2011-03-24 11:41 UTC (permalink / raw)
  To: ntg-context

Am Thu, 24 Mar 2011 11:50:47 +0100 schrieb Philipp Gesang:


>>> (You’re going to have to declare the table “chessfss” globally
>>> for this to work.)
>> 
>> The chessfss.lua has a "return Table" at the end which declares the
>> table chessfss. 
>> 
>> To quote from http://lua-users.org/wiki/LuaModuleFunctionCritiqued:
>> 
>> "The problems above can be avoided by not using the module function
>> but instead defining modules in the following simple way: [*1][*2] 
> 
> Of course, that’s the Lua way. I can’t guess what you’re up to
> but if it’s going to eventually become a module, the “chessfss”
> table should not pollute the global namespace. There are
> canonical locations (check luat-ini.lua) where the functions and
> data should go:
> 
>   http://www.ntg.nl/pipermail/ntg-context/2010/054982.html
> 
> So you might be better off dropping “require” altogether and just
> conclude your module with a line like:
> 
>   thirddata = thirddata or { }
>   thirddata.chessfss = chessfss
> 
> instead of returning a table, then loading it with “loadluafile”.
 
I'm not writing a module but virtual fonts, and they can be used
with context and latex. So whatever I will be doing should not be
context specific. But I will test if I can keep the chessfss-table
local, and if not put it in thirddata if it exists.


-- 
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] 5+ messages in thread

end of thread, other threads:[~2011-03-24 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-24  9:50 search path for require(...) Ulrike Fischer
2011-03-24 10:14 ` Philipp Gesang
2011-03-24 10:34   ` Ulrike Fischer
2011-03-24 10:50     ` Philipp Gesang
2011-03-24 11:41       ` Ulrike Fischer

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).