Re: Block comment and unescape string

2009-05-08 Thread Henrik Sarvell
Hi Kriangkrai (what is your short name?).

This is a matter of taste, I actually like the func way because that
makes it easy for me to differentiate them from system functions.

Check out the xhtml.l file for both those functions and the tag function.

/Henrik

On Fri, May 8, 2009 at 3:24 PM, Kriangkrai Soatthiyanont
kks...@gmail.com wrote:
 Hi Alex,

 (let (Clr #EEE Cls xxx)
 =A0 =A0(fill
 =A0 =A0 =A0 '(html
 =A0 =A0 =A0 =A0 =A0(body (style background-color: Clr)
 =A0 =A0 =A0 =A0 =A0 =A0 (div (class Cls)) ) )
 =A0 =A0 =A0 '(Clr Cls) ) )

 One problem with 'fill' is that the expressions to fill cannot be
 anonymous (it must be the result of a variable), e.g. to fill the
 result of (pack # EEE), we must (setq Clr (pack # EEE)) first
 before using 'fill'.


 But why should this be necessary, if 'html' and such functions could han=
dle their arguments in the normal way?
 (out t.html
 =A0 =A0(let (Clr #EEE =A0Cls xxx)
 =A0 =A0 =A0 (html 0 Title lib.css (cons background-color Clr)
 =A0 =A0 =A0 =A0 =A0(div Cls
 =A0 =A0 =A0 =A0 =A0 =A0 Something in the DIV ) ) ) )

 That's true if such functions (e.g. div, ul, ...) already exist.
 If not, we must create them (and be bloated?), or create a generic
 function (e.g. tag), which must be the case if tag names can be
 anything, like in XML, unlike HTML/XHTML, where tag names are limited.
 But with that, the code does not look nice any more, compare:

 =A0 (html 
 =A0 =A0 =A0(tag 'div NIL
 =A0 =A0 =A0 =A0 (tag 'ul NIL
 =A0 =A0 =A0 =A0 =A0 =A0(tag 'li NIL ...)
 =A0 =A0 =A0 =A0 =A0 =A0... )))

 with

 =A0 (html 
 =A0 =A0 =A0'(div NIL
 =A0 =A0 =A0 =A0 (ul NIL
 =A0 =A0 =A0 =A0 =A0 =A0(li NIL ...)
 =A0 =A0 =A0 =A0 =A0 =A0... )))


 Best regards,
 KS


 On 5/8/09, Alexander Burger a...@software-lab.de wrote:
 Hi Kriangkrai,

 It would be great if PicoLisp have quasi-quotation, so the code
 could be something like:

 (out t.html
 =A0 =A0(sxml
 =A0 =A0 =A0 (let (Clr #EEE Cls xxx)
 =A0 =A0 =A0 =A0 =A0`(html
 =A0 =A0 =A0 =A0 =A0 =A0 (body (@ style background-color: ,Clr)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(div (@ class ,Cls)) )

 There is indeed something simlar, though not on the base of read
 macros but of a function ('fill'). You can either write

 =A0 =A0(let (Clr #EEE Cls xxx)
 =A0 =A0 =A0 (fill
 =A0 =A0 =A0 =A0 =A0'(html
 =A0 =A0 =A0 =A0 =A0 =A0 (body (style background-color: Clr)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(div (class Cls)) ) )
 =A0 =A0 =A0 =A0 =A0'(Clr Cls) ) )

 or use pattern variables (with '@')

 =A0 =A0(let (@Clr #EEE @Cls xxx)
 =A0 =A0 =A0 (fill
 =A0 =A0 =A0 =A0 =A0'(html
 =A0 =A0 =A0 =A0 =A0 =A0 (body (style background-color: @Clr)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(div (class @Cls)) ) ) ) )


 But why should this be necessary, if 'html' and such functions
 could handle their arguments in the normal way? A real working
 example would be

 =A0 =A0(load lib/http.l lib/xhtml.l)

 =A0 =A0(out t.html
 =A0 =A0 =A0 (let (Clr #EEE =A0Cls xxx)
 =A0 =A0 =A0 =A0 =A0(html 0 Title lib.css (cons background-color Cl=
r)
 =A0 =A0 =A0 =A0 =A0 =A0 (div Cls
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Something in the DIV ) ) ) )

 Cheers,
 - Alex
 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Henrik Sarvell
Alright, up to Alex but if it makes the interpreter slower then I'm against=
 it.

The reason I'm using Pico Lisp is because it's faster than the
alternatives (Ruby, Python).

Maybe it's time then to start with a Maxi Pico Lisp? You could put the
Maxi version under Mercurial control, whenever Alex releases a new
version of Normal Pico Lisp you simply pull his stuff into your fork
and voila a new version of Maxi.

Why Mercurial and not Subversion or Git? Because it's better, it's the
best version control system that has ever existed.

http://www.selenic.com/mercurial/wiki/

/Henrik


On Fri, May 8, 2009 at 3:34 PM, Kriangkrai Soatthiyanont
kks...@gmail.com wrote:
 Hi Henrik,

 My purpose of block comment is not to comment out multiple lines, for
 that I would use single line comments too.

 I would use block comment to comment out small part in a line, e.g.

 =A0 (list 1 2 #{3 4}# 5)

 or to comment within context, e.g.

 =A0 =A0 =A0 =A0(de f (A #{...}# B #{...}#)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0... )

 Best regards,
 KS


 On 5/8/09, Henrik Sarvell hsarv...@gmail.com wrote:
 I've implemented simply selecting a slew of lines in my editor,
 hitting ctrl-t and they're all single line commented. I'm sure this
 can be done in VIM too with some work (if it isn't there already).

 Anyway, after doing that I never wished for multi line comments again.

 Let's not make the interpreter more complicated for nothing.

 /Henrik

 On Fri, May 8, 2009 at 10:02 AM, Alexander Burger a...@software-lab.de
 wrote:
 On Fri, May 08, 2009 at 09:48:05AM +0200, Alexander Burger wrote:
 Because: If the commented text contains the pattern #{ or }# in a
 context where it is not relevant as a comment (e.g. in a symbol name o=
r
 a string), the nesting will break.

 Sorry, I'm stupid!

 Nesting or not, these block comments will always break if }# is
 contained in a non-relevant context.

 So we might as well make it nesting.

 Cheers,
 - Alex
 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Alexander Burger
Hi Kriangkrai,

 One problem with 'fill' is that the expressions to fill cannot be
 anonymous (it must be the result of a variable), e.g. to fill the

That's true.

 That's true if such functions (e.g. div, ul, ...) already exist.

Yes, they do, e.g. in lib/xhtml.l. They are a little bit described in
doc/app.html.

The other possibility is (as mentioned by Tomas) to direcly use
the XML library lib/xml.l.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Kriangkrai Soatthiyanont
Hi Henrik,

You may call me KS.

It's NOT my intention to fork Pico Lisp! I just need some features. If
I can do them myself, I implement and share them back. If I do not
know how, I request them or ask for an alternative solution. It's OK
for my contribution to not be included in standard Pico Lisp
distribution, or for my requests to not be implemented.

And for the block comment code, I do not see that it would slow down
the interpreter in a significant way! The code is triggered only when
there is '{' after '#'.

Best regards,
KS
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Alexander Burger
Hi Henrik,

 Alright, up to Alex but if it makes the interpreter slower then I'm against=
  it.

No reason to worry. I'm sure the impact is minimal.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Henrik Sarvell
Is Kriangkrai acceptable, too?

Kriangkrai Soatthiyanont sounds Thai, but maybe I was mistaken, if I
wasn't there is a short, usually 3 letter name that is easier to use
:-).

/Henrik


On Fri, May 8, 2009 at 4:43 PM, Alexander Burger a...@software-lab.de wrote:
 Hi Kriangkrai,

 You may call me KS.

 Really? I was also not sure how to call you ;-)
 Is Kriangkrai acceptable, too?

 Cheers,
 - Alex
 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-08 Thread Kriangkrai Soatthiyanont
Hi Alex and Henrik,

 Is Kriangkrai acceptable, too?
Sure. Kriangkrai is my first name. KS is from K for Kriangkrai (my
first name) and S for Soatthiyanont (my surname).

 Kriangkrai Soatthiyanont sounds Thai
Yes, I'm Thai. Sawadee Krub :-)

Best regards,
KS
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-07 Thread Kriangkrai Soatthiyanont
Hi Alex,

With unescaped string, we don't need to worry escaping (e.g. \
\^), well except ensuring that there is no $} in the string. With
that, we can generate files easily, e.g.

(out t.html (prin {$htmlbody
style=background-color:#EEE...div
class=xxx.../div.../body/html$}))

Best regards,
KS

On Thu, May 7, 2009 at 7:45 PM, Alexander Burger a...@software-lab.de wrote:
 Hi Kriangkrai,

 I have a patch to add block comment (#{}#) and unescape string
 ({$.$}) syntax.

 I think the block comments are a great idea. Such a feature was missing,
 and I like the above syntax. But I'm a bit reluctant about the unescaped
 strings. Why do you think they might be needed?

 Cheers,
 - Alex
 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-07 Thread Alexander Burger
Hi Kriangkrai,

 But what if we want to mix it with expressions?
 
(let (Clr #EEE  Cls xxx)
   (pack {$htmlbody style=3Dbackground-color:$} Clr {$
  div class=3D$} Cls {$
  /div
  /body/html$} ))

Then it gets indeed a bit clumsy, but you can use multiple 'here's and
suitable delimiters:

(let (Clr #EEE  Cls xxx)
   (here 1)
   (prin Clr)
   (here 2)
   (prin Cls)
   (here) )
htmlbody style=background-color:1
 div class=2
 /div
/body/html

I see this is not really equivalent, as it lets you not directly write
the text inline, and also does not allow operations on the strings like
'pack' in your example, but I feel that the unescaped strings are not
the right thing to put into general purpose. Would it be OK if I include
only your #{span comment}# into the standard distribution?

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Block comment and unescape string

2009-05-07 Thread Kriangkrai Soatthiyanont
Hi Alex,

Yes, it's ok to include only block comment :-)

Best regards,
KS


On Fri, May 8, 2009 at 1:20 AM, Alexander Burger a...@software-lab.de wrot=
e:
 Hi Kriangkrai,

 But what if we want to mix it with expressions?

 =A0 =A0(let (Clr #EEE =A0Cls xxx)
 =A0 =A0 =A0 (pack {$htmlbody style=3D3Dbackground-color:$} Clr {$
 =A0 =A0 =A0 =A0 =A0div class=3D3D$} Cls {$
 =A0 =A0 =A0 =A0 =A0/div
 =A0 =A0 =A0 =A0 =A0/body/html$} ))

 Then it gets indeed a bit clumsy, but you can use multiple 'here's and
 suitable delimiters:

 (let (Clr #EEE =A0Cls xxx)
 =A0 (here 1)
 =A0 (prin Clr)
 =A0 (here 2)
 =A0 (prin Cls)
 =A0 (here) )
 htmlbody style=3Dbackground-color:1
  div class=3D2
  /div
 /body/html

 I see this is not really equivalent, as it lets you not directly write
 the text inline, and also does not allow operations on the strings like
 'pack' in your example, but I feel that the unescaped strings are not
 the right thing to put into general purpose. Would it be OK if I include
 only your #{span comment}# into the standard distribution?

 Cheers,
 - Alex
 --
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe