Hi,

I just realized that it might be possible to implement curly infix as
normal macro and still have it easily readable when using sweet
expressions.

I did a very partial port of curly to emacs lisp, but only as macro,
and it struck me, that sweet gets rid of the enclosing braces.

Currently I can do this in normal elisp code:

({ 2 + 4 })

With sweet that would transform directly to 

{ 3 + 4 }

For nested formulas, it might be possible to have the recursivity in
the infix-macro, so we could simply use

({ 3 + 4 + { 5 * 6 } })

In sweet that would transform to 

{ 3 + 4 + { 5 * 6 } }

without having to change the reader. 

Also this could be a very simple point of entry. TODO for that: make
the {-macro recognize nested curly-braces and parse them recursively,
as if they had been called as ({.

Then a very basic sweet expression reader could simply consist of a
deterministic whitespace-to-brackets conversion and it would have
curly-infix for free (the macro could even be implemented in sweet).

Best wishes,
Arne

------ the port ------

; most of this just taken from 
http://sourceforge.net/p/readable/code/ci/0dec1078327822129bbe4f36c667dfed443c2c/tree/curly-infix.cl
 )

(setq } nil)

; Return alternating parameters in a lyst (1st, 3rd, 5th, etc.)
(defun alternating-parameters (lyst)
  (if (or (null lyst) (null (cdr lyst)))
    lyst
    (cons (car lyst) (alternating-parameters (cddr lyst))))) 

; Transform a simple infix list - move the 2nd parameter into first position,
; followed by all the odd parameters. Thus (3 + 4 + 5) => (+ 3 4 5).
(defun transform-simple-infix (lyst)
  (cons (nth 1 lyst) (alternating-parameters lyst))) 

(defmacro { (&rest args)
  (transform-simple-infix args))


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to