Raffael Cavallaro wrote:
> Though lisp macros are not optimized for low-level character juggling,
> read macros can be used for this, and the existing infix.lisp is a good
> example.
Is Lisp's infix macro extensible? Can you insert a new precedence level and
add new operators to it?
--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet
On 2007-05-19 12:14:19 -0400, Jon Harrop <···@ffconsultancy.com> said:
> Is Lisp's infix macro extensible? Can you insert a new precedence level and
> add new operators to it?
Precedence (or operator-ordering as it's called in the code) is
contained in a single defparameter form. New operators would require
insertion into this list and you would need to add a
define-token-operator form for the new operator - most of the existing
ones are 2 to 5 lines long. If the new operator were more than one
character, you'd need a define-character-tokenization form for each of
the leading characters - these are typically 3 to 10 lines. Take a look
at the code - I'm sure a master of such a superior language as OCaml
will find it child's play ;^)
Raffael Cavallaro wrote:
> On 2007-05-19 12:14:19 -0400, Jon Harrop <···@ffconsultancy.com> said:
>> Is Lisp's infix macro extensible? Can you insert a new precedence level
>> and add new operators to it?
>
> Precedence (or operator-ordering as it's called in the code) is
> contained in a single defparameter form. New operators would require
> insertion into this list and you would need to add a
> define-token-operator form for the new operator - most of the existing
> ones are 2 to 5 lines long. If the new operator were more than one
> character, you'd need a define-character-tokenization form for each of
> the leading characters - these are typically 3 to 10 lines. Take a look
> at the code
Thanks. Can this be done without altering (or copying) the source code of
infix.lisp?
--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet
In article <························@ptn-nntp-reader02.plus.net>,
Jon Harrop <···@ffconsultancy.com> wrote:
> Raffael Cavallaro wrote:
> > On 2007-05-19 12:14:19 -0400, Jon Harrop <···@ffconsultancy.com> said:
> >> Is Lisp's infix macro extensible? Can you insert a new precedence level
> >> and add new operators to it?
> >
> > Precedence (or operator-ordering as it's called in the code) is
> > contained in a single defparameter form. New operators would require
> > insertion into this list and you would need to add a
> > define-token-operator form for the new operator - most of the existing
> > ones are 2 to 5 lines long. If the new operator were more than one
> > character, you'd need a define-character-tokenization form for each of
> > the leading characters - these are typically 3 to 10 lines. Take a look
> > at the code
>
> Thanks. Can this be done without altering (or copying) the source code of
> infix.lisp?
\|||/
(o o)
|~~~~ooO~~(_)~~~~~~~|
| Please |
| don't feed the |
| TROLL! |
'~~~~~~~~~~~~~~Ooo~~'
|__|__|
|| ||
ooO Ooo
--
http://lispm.dyndns.org
(message (Hello 'Jon)
(you :wrote :on '(Sat, 19 May 2007 18:31:04 +0100))
(
JH> Thanks. Can this be done without altering (or copying) the source code
JH> of infix.lisp?
i'm sorry, i've missed which "infix.lisp" are you talking about, but in
three i've found on the web it looks quite straightforward -- define new
operator, functions and insert into list.
believe me or not, but you can insert values inside lists in LISP!
moreover, this http://plaza.ufl.edu/lavigne/resources/infix/infix.lisp
appears to have such macro:
(definfix my-infix-symbol
:precedence 40
:function-name +)
looks quite extensible, right?
i can say more, even if you've found some patalogic infix.lisp that does not
allow to change precendence, Lisp has very powerful reflection and
introspection, so it would be quite easy to extend it even if author
specially made it non-extensible!
but most sane authors just keep data in lists and hash-tables, than can be
modified afterwards (i repeat twice because our clever ML programmer failed
to understand when Raffael told him "insertion into this list". Lisp is not
Haskell, lists are mutable here, no need to alter code)
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"I am everything you want and I am everything you need")
In article <························@ptn-nntp-reader02.plus.net>,
Jon Harrop <···@ffconsultancy.com> wrote:
> Raffael Cavallaro wrote:
> > Though lisp macros are not optimized for low-level character juggling,
> > read macros can be used for this, and the existing infix.lisp is a good
> > example.
>
> Is Lisp's infix macro extensible? Can you insert a new precedence level and
> add new operators to it?
\|||/
(o o)
|~~~~ooO~~(_)~~~~~~~|
| Please |
| don't feed the |
| TROLL! |
'~~~~~~~~~~~~~~Ooo~~'
|__|__|
|| ||
ooO Ooo
--
http://lispm.dyndns.org