|
So as u see, coming to TXR without previous knowledge in Lisp, I realize that I have to learn how things are done in Lips in order to get some mileage out of TXR.I'd really love to jump right in, but if one doesn't know any lisp/scheme before hand, there's quite a bit of a learning curve.I think that with "tutorial" style documentation to complement the "man page" documentation, TXR could really shine.I'm still in the learning stages of TXR and TXR Lisp, but I can really see how this is an extremely efficient text manipulation tool which might probably even be more powerful and efficient than Perl, which as understand was the defacto language for text processing.I feel that Kaz has put a lot of thought into what TXR is best suited for and that is manipulation of text.TXR Lisp has a lot of functionality built around manipulation of strings, which seem to be lacking in other Lisps/Schemes.Roman, I don't think Jetbrains would address what I want to do. It would be something that would need to be distributed to users and be run as a script. Im not really parsing, more like a glorified "search and replace". But what I find interesting is the notion that by making a small change to my input data file, I am in fact transforming it into a LISP program, which can then simply be run without modification, provided I have defined my functions somewhere and load them with @(load ...) (well, that's what I hope will be possible anyways!).Kaz/Roman,Thank you for your help.For example, in my simple test, I can't seem to figure out how to get things to output without parens:
@(do
(defun bold(arg1)
(print '(\*[BLD]))
(print arg1)
(print '(\*[PREV]))
)
; Simple test. Should output \*[BLD]hello\*[PREV]
(bold 'hello)
)This outputs: (\* [BLD])hello(\* [PREV]) with parens.and, if I change my input to (bold "hello"), this outputs hello with quotes: (\* [BLD])"hello"(\* [PREV])On Wed, Sep 24, 2014 at 12:24 PM, Kaz Kylheku <kaz@kylheku.com> wrote: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:
Thanks!So my question is if I can define TXR LISP functions like (bold arg), (size arg1 arg2) and "import" them into a TXR prorgam?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!The idea is to generate output from the input, for example, could be Groff, LaTex, HTML, etc...=> (size +2 (bold (up 3 "text")))<size +2, bold, up 3<text><up 3<text><smallcaps<text><bold<text>In my project I have some simple markup language I have defined which translated itself very nicely to lisp code. For example:Where myfunctions is an external module in which I have defined some functions.What I mean is, in Scheme I can do the following:Hello list,I would like to know if it's possible to "import" code or modules into TXR Lisp.
(require myfunctions)Which converted into LISP would look something like:(bold "text")(smallcaps "text")(up 3 "text")Or as nested inline commands:
--
Memorize Japanese Characters with Tankan.
This message was posted to the following mailing lists: | ||||
---|---|---|---|---|
TXR Users Mailing list info | Nearby messages |
Kaz'z Mailing List Archives adminstered by Kaz | Lurker (version 2.3, substantialy hacked by Kaz). Icon artwork from VisualPharm. |