Re: Using Lisp Modules

 new new list compose Reply to this message Top page
Attachments:
+ (text/plain)
+ (text/html)

Delete this message
Author: Kaz Kylheku
Date:  
To: Yves Cloutier
CC: txr-users
Subject: Re: Using Lisp Modules

Hi Yves,

I haven't implemented a function to load just Lisp code. The main TXR language has a @(load ...) directive for loading dependent .txr files. You can put Lisp definitions into them; just wrap it all with @(do ...).

I implemented load it so that if the path is relative, it resolves relative to the directory of the file which the @(load ...) directive occurs, similarly to how #include "relpath.h" works in C compilers or the way Windows programs look for DLL's. So it is easy to break a program into multiple files, regardless of where it is placed and invoked from.

On 23.09.2014 18:58, Yves Cloutier wrote:

Hello list,

I would like to know if it's possible to "import" code or modules into TXR Lisp.

What I mean is, in Scheme I can do the following:

(require myfunctions)

Where myfunctions is an external module in which I have defined some functions.

In my project I have some simple markup language I have defined which translated itself very nicely to lisp code.  For example:

<bold<text>
<smallcaps<text>
<up 3<text>

Which converted into LISP would look something like:

(bold "text")
(smallcaps "text")
(up 3 "text")
 
Or as nested inline commands:

<size +2, bold, up 3<text>

=> (size +2 (bold (up 3 "text")))

The idea is to generate output from the input, for example, could be Groff, LaTex, HTML, etc...

Initially I thought of using the pattern matching feature of TXR to define tokens, match them and do something accordingly.  But Now I'm sort of cluing in to the brilliance of LISP languages that code is data and data is code paradigm, and that instead, I could just translate my input text file into LISP form and just do a (eval ) which just executes the entire document as a LISP program!

So my question is if I can define TXR LISP functions like (bold arg), (size arg1 arg2) and  "import" them into a TXR prorgam?

Thanks!


 

--

Memorize Japanese Characters with Tankan.