Mercurial Repository

2010-04-25 Thread José Romero
Hi, If anyone is interested, I let you know I'm keeping a
mercurial repository up to date with the latest picoLisp.tgz (updated
automatically with a cron script) on Google Code
http://code.google.com/p/picolisp/source/list

cheers,
Jos=C3=A9
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: solicting user stories of picolisp

2010-07-19 Thread José Romero
El Mon, 19 Jul 2010 18:46:55 +0200
Alexander Burger  escribi=C3=B3:
> On Mon, Jul 19, 2010 at 04:39:08PM +0200, Mateusz Jan Przybylski
> wrote:
> > The lecturer never heard of Lisp before; after listening to my
> > explanations he wrapped it up with:
> >  ``So this Lisp is a newfangled language, quite like Ruby, right?''
> > Geez...
>=20
> I'm deeply shocked!

Lisp Never gets old
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: PL vs. BSD License

2010-08-02 Thread José Romero
El Mon, 2 Aug 2010 15:20:06 +0800
Edwin Eyan Moragas  escribi=C3=B3:
> Hi Alex, all,
>=20
> On Mon, Aug 2, 2010 at 2:29 PM, Alexander Burger
>  wrote:
> > Hi all,
> >
> > as this discussion popped up recently and in the past, and will
> > surely pop up in the future: What do you think if PicoLisp were
> > released under the BSD license instead of GPL?
>=20
> i go for BSD.
>=20
> >
> > My reason for asking this is simple: On several occasions I
> > experienced that the acceptance of PicoLisp is limited by the GPL.
> > Companies are reluctant to use it because they are afraid of being
> > forced to publish their little secrets. Their fear is sometimes
> > rational and sometimes not, but the effects are the same. For me it
> > is critical, as my economic survival depends on it.
>=20
> the way i understand it (from reading all of the pros and cons posts
> of GPL vs BSD over the net for quite some time) is that the GPL forces
> you to publish changes when you want to distribute the code outside of
> the company. the most clear statement i have read somewhere tells me
> "the GPL is a distribution license". i think that captures the spirit
> of the GPL. or most of it.
>=20
Like you said, the GPL is a distribution license, it only applies when
the code is distributed, it does not force you to *publish* the changes
or absolutely _anything_, it forces you to give the changes to the
*recipient* of the modified binaries, which most of the time will be
the same company anyway (a datacenter move for example).

Pico's architecture doesn't seem very ready for embedding, but if
you alex want to go in that direction, i'd suggest LGPL for the
interpreter code, as Guile uses. Or in any way right now, LGPL or BSD
for the standard library, to prevent linking issues that could arise as
Edwin pointed out earlier. I could add too, a BSD implementation of the
PLIO (that i'm coding myself right now)

> >
> > Ideologically, I prefer the GPL. It guarantees that "freedom"
> > propagates. But it does this by cutting down on freedom, so it is
> > schizophrenic. I used to compare the situation with freedom in a
> > society: A society should not give an individual member so much
> > freedom that he can make himself a dictator and thus destroy
> > freedom. But this comparison is wrong. Using free software in a
> > non-free project doesn't decrease its freedom; it just doesn't
> > increase it the way the GPL tries to enforce. So is this just much
> > ado about nothing?
>=20
> this is a complex issue and i am not an expert. my additional
> arguments would be:
>=20
> 1) the BSD license does not force one to publish changes. good for
> companies. the GPL does not enforce this too *unless* you distribute
> your changes to pre-existing GPL code.
>=20
> 2) the BSD license still ensures that the code remains free. the GPL
> does not guarantee that changes in the pre-existing code will be made
> publicly available (see point 1).
>=20
The BSD doesn't guarantee that either, in fact BSD never guarantees
that the changes will go back.

> 3) the GPL is complex. so many ifs. i'm not keen on using complex
> things.

In that one i agree, the GPL is a huge legal document, and as such so
many people don't read it before talking about it.

>=20
> best regards,
>=20
> eyan
>=20
> PS:
> hat tip to Alex for PicoLisp and bringing this issue up in the list.

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


Re: wiki password

2010-10-26 Thread José Romero
El Tue, 26 Oct 2010 14:31:17 +0200
Alexander Burger  escribi=C3=B3:
> On Sat, Oct 23, 2010 at 12:18:45AM +0200, Javier wrote:
> > Alex, please add a feature to reset the password, as I don't
> > remember
>=20
> Thinking about it: What would be the best way?

Try this:

1. When the user presses reset pass the button on a valid user, generate
a random password.
2. Store it in a special field in the User object (rpass?) along
with the date of which that random pass was generated (rdate?)
3. Send it to the user in an email like this:
Subject: Password reset for user (username) at (name-of-the-site)

Someone requested a password reset for your account at
(name-of-the-site), if you indeed want to reset your password, please
log in with the following information:
=09
Username: (username)
Password: (rpass)

If you don't want to change your password now, just ignore this email,
the above credentials will expire in 24 hours, or the next time you
log in normally.

4. Modify the login process in the following way:
* First check for the stored password as usual, if it's valid,
  just log in normally, and wipe rpass and rdate if they exist.
* If the regular pass fails, check whether rpass is not null,
  and rdate is not more than one day in the past. If the
  password matches, log in the user and take him/her to the
  password change form.

I think the above procedure should be acceptably easy to use, implement
and secure.

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


Re: wiki password

2010-10-26 Thread José Romero
El Tue, 26 Oct 2010 16:57:10 +0200
Alexander Burger  escribi=C3=B3:
> Hi Jos=C3=A9,
>=20
> > 1. When the user presses reset pass the button on a valid user,
> > generate a random password.
> > 2. Store it in a special field in the User object (rpass?) along
> > with the date of which that random pass was generated (rdate?)
> > 3. Send it to the user in an email like this:
> > Subject: Password reset for user (username) at (name-of-the-site)
> > ...
>=20
> Thanks, this sounds reasonable.
>=20
> The only problem I see is sending the new password in an unencrypted
> email. Shouldn't be a big risk, I suppose. Otherwise, we could extend
> the user account so that everyone can deposit his public key, and
> enable this password reset functionality only for people who have
> done so.
>=20
> Cheers,
> - Alex

Well many sites use this scheme, some with special links and such, the
risk is greatly disminished though because the user just needs to log
in to render those credentials invalid.
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: wiki password

2010-10-26 Thread José Romero
El Wed, 27 Oct 2010 01:00:38 +0800
Boh Yap  escribi=C3=B3:
> hi,
>=20
> send 2 emails, the 1st informing that passwd reset is activated and a
> following email will contain the temp. passwd.
>=20
> then send the passwd in the 2nd email. And if the 2nd email does not
> mention an acct name, then its reasonably safe.
>=20
That hurts usability, besides, if someone is logging your email you're
in trouble anyway. Most sites send an special link to activate the
account reset, that is at most as safe as the method i detailed, and
mine isn't significantly harder to use, and it's easier to implement!
Also note that the random password is not permanent, it loses validity
after certain time (i suggested 24 hours, but you can make it as
little as 1 hour or a few minutes if you're paranoid) OR if you log in
(be it with your normal password or after using the reset), that way
abuse of the feature is less problematic on active accounts (the ones
that are most worth probably, anyway). You can also introduce blocks to
the button if it presents a problem (for example, you can only request a
reset every 2 days). But, really, only add that kind of complexity if
abuse proves to be a problem, no need to overengineer it :3

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


Re: Tcpdump and getopts

2011-03-04 Thread José Romero
On Fri, 4 Mar 2011 08:59:09 +0100
Alexander Burger  wrote:

> Hi meinbg,
>=20
> > Let's see if this mail gets through:
>=20
> Yes, perfectly.
>=20
>=20
> > Tcphex is a tcp proxy that gives a realtime hexdump of data sent
> > both ways. ...
> > All comments appreciated.
>=20
> Thanks for your contribution! It looks like you did a really good job!
> Perhaps you might also want to publish it in the PicoLisp google code
> repository?
>=20
>=20
Hi Meinbg, I'm the current maintainer of the picolisp-addons repo at
google code, if you want to put your tool in that repo drop me a line,
I'll have to make some little modifications to accommodate for the
directory structure and documentation :) (that may still change because
we haven't set everything in stone)

> [snip]

Cheers,
Jos=C3=A9
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: opt/pilog.l

2011-03-11 Thread José Romero
On Fri, 11 Mar 2011 21:15:16 +0100
Alexander Burger  wrote:

> Hi Ana,
> 
> On Sat, Mar 12, 2011 at 01:12:21AM +0800, Ana Zgombic wrote:
> > oops. sent too soon. found out it is used by misc/pilog.l.
> 
> Oops indeed! I was not aware that it is referred to by "misc/pilog.l".
> 
> In fact, "opt/" was moved to an external package recently, so we have
> a broken dependency now.
> 
> Jose: What do you think? Could we also put "misc/pilog.l" into the
> add-ons?
> 
> 
Done, it's in the examples directory of the addons repo :)

> > in any case, misc/* are for tests, right?
> 
> Yes, and for examples, code fragments of typical usage.
> 
> To your original question: "opt/" was intended for such add-ons (like
> the 'findall' provided by Clemens). And it still is.
> 
> Cheers,
> - Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: digging dotted pairs

2011-03-13 Thread José Romero
On Mon, 14 Mar 2011 04:49:44 +0800
Ana Zgombic  wrote:

> Hi list,
>=20
> i don't dig dotted pairs. it's hard for me to reconcile the existence
> of a dotted pair when there's a more general representation of it (a
> plain list).
>=20
> like in the design of the (tag) API for xhtml generation. why use a
> dotted pair instead of a two-element list?
>=20
> searching the net for examples and meanings doesn't give much.
>=20
> any insights on this?
>=20
This is something funny in lisp, dotted pairs, even though the syntax
is more complex, is actually the simplest non-atomic data structure in
picolisp, the list systax is actually a shortcut for a string of dotted
pairs: (1 2 3) is the same as (1 . (2 . (3 . NIL)), you can test that
writing the long version in the picolisp repl (interactive
interpreter), both versions will print (1 2 3), because they are the
same.=20

The dotted pair is also called "cons cell", it's the building block for
more complex lisp data structures, like lists or trees. Each cons cell
has two parts, it's CAR and CDR (they used to be acronyms that used to
mean something, but now they are just old relics) In a list, cons cells
are chained like cars in a train, they usually have their "payload" in
the CAR (like trains) and a pointer to the next cell in the list in
it's CDR, going back to the (1 2 3) example:
=20
 * Let's see the first cell we see it has the number one in it's CAR,
   and a cell in it's CDR.=20

 * that second cell has a number in it's CAR and another cell in it's
   CDR, and so on 'till the last one, where it has a special value
   "NIL", NIL literally means "Nothing", so our lisp machine reads it
   as "Nothing follows"

+---+---+  +---+---+  +---+---+
| 1 |  --->| 2 |  --->| 3 |  ---> NIL
+---+---+  +---+---+  +---+---+

Kinda looks like a train, huh? (if it doesn't you need to read this
with fixed-width font)

Now, what if instead of nil, we link the last CDR to the first cell?

+---+---+  +---+---+  +---+---+
 ,->| 1 |  --->| 2 |  --->| 3 |  ,
 |  +---+---+  +---+---+  +---+---+  |
 '---'

We got a circular list!, the syntax to write such a thing in picolisp
is (1 2 . 3)

And what is the empty list in picolisp? NIL, yes, NIL is a pretty
special beast, it's not only false, an empty symbol, it's also an empty
list! you can call him NIL: The king of Nothing-ham.

You can also link other cells in other shapes, putting cells in CARs
and CDRs to form some pretty data structures like trees or other graphs.

Better described here http://en.wikipedia.org/wiki/Cons#Lists

> thank you.
>=20
> Ana
>=20
> PS:
>=20
> i don't mean to test everybody's patience with my questions. i'm
> really just learning. :)
>=20

LOL i cant believe i ended up writing that wall of text, i hope it
helps :3

Cheers,
Jos=C3=A9
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: UB-Tree support

2011-05-20 Thread José Romero
 > BTW, I felt that I should finally try Twitter! So I created an
> account a few days ago, and just now I twittered (tweeted, twote?)
> the good news about the UB-Tree into the world :D
> 
> @Henrik: You are the first (and only one so far) I'm following ;-)
> Anybody else?
>
Following you! i'm @cyborgar :]
 
> Cheers,
> - Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Multiple asynchronous HTTP POSTs and call versus in - a word of

2011-06-20 Thread José Romero
On Tue, 21 Jun 2011 00:33:48 +0700
Henrik Sarvell  wrote:

> Hi Everyone.
> 
> New article in the wiki:
> http://picolisp.com/53823/59880452264949525~-2-1h.html based on
> today's adventures.

And this is why putting session data in the URL is a terrible practice,
correct link: http://picolisp.com/5000/-2-1h.html

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: IRC dump for #picolisp

2011-07-08 Thread José Romero
On Sat, 9 Jul 2011 12:59:11 +0700
Henrik Sarvell  wrote:

> Does anyone know how this is done?
> 
> Here is an example from #geany:
> http://irc.geany.org/logs/old/log_20101023.html
> 
> At the bottom it says "Stats generated by
> irclog.py<>on Sat Oct 23
> 23:58:01 2010 (times in UTC, will be generated every 24
> hours)" but I have no idea how it's setup.
> 
> I don't know, perhaps it would be redundant, or maybe discourage
> higher quality communication via the mailing list?

Just read the script (http://irc.geany.org/logs/irclog.py) , all it
does is generate a fancy HTML page from a plain text log file, i
suppose the log file is provided by a bot.
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Equivalenz of (quote (...)) and '(...)

2011-09-28 Thread José Romero
On Wed, 28 Sep 2011 20:27:15 +0200
Thorsten  wrote:

> 
> Hi list, 
> I thought that  (quote (...)) and '(...) should be equivalent, but I
> get different results with the following two versions of a little
> test program:
> 
> # version A
> (prog 
>(let (tab  '((1 2 3 ) (4 5 6) (7 8 9)))
>(+ (caar tab) (caar (cdr tab )
> 
> ---
> result:
> : -> 5
> 
> # version B
> (prog 
>(let (tab  (quote ((1 2 3 ) (4 5 6) (7 8 9
>(+ (caar tab) (caar (cdr tab )
> 
> ---
> result:
> : !? (+ (caar tab) (caar (cdr tab)))
> (1 2 3) -- Number expected
> 
> 
> Thats a bit strange - at least for me ;)
> cheers
> Thorsten
> 

See http://picolisp.com/5000/!wiki?ArticleQuote :3 that article pretty
much says why it behaves the way it does.

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: The many uses of @

2011-11-08 Thread José Romero
On Tue, 08 Nov 2011 20:29:39 +0100
Thorsten  wrote:

> 
> Hi list,
> 
> when reading Picolisp source code I often find myself a bit confused
> with regards to the meaning of @ in the context of the source code.
> Therefore I tried to make a table that summarizes all possible
> meanings of @ in Picolisp in one place (see attached html-file
> below). Please let me know what I've missed or where I misunderstood
> something.
> 
> If you think the table is worth it, I could make a wiki-page for it,
> but I don't have access to the picolisp-wiki. 
> 
> Cheers

'text also uses @ http://software-lab.de/doc/refT.html#text
It's also useful to note that in short-circuit evaluation style
functions like 'and, @ always holds the result of the previously
evaluated argument, as you can see in this typical PicoLisp line:

  (and and (@ (min @ 5) (prinl @) (gt0 (dec @)) .))

;)
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: The many uses of @

2011-11-08 Thread José Romero
On Tue, 8 Nov 2011 17:10:41 -0300
José Romero  wrote:

> On Tue, 08 Nov 2011 20:29:39 +0100
> Thorsten  wrote:
> 
> > 
> > Hi list,
> > 
> > when reading Picolisp source code I often find myself a bit confused
> > with regards to the meaning of @ in the context of the source code.
> > Therefore I tried to make a table that summarizes all possible
> > meanings of @ in Picolisp in one place (see attached html-file
> > below). Please let me know what I've missed or where I misunderstood
> > something.
> > 
> > If you think the table is worth it, I could make a wiki-page for it,
> > but I don't have access to the picolisp-wiki. 
> > 
> > Cheers
> 
> 'text also uses @ http://software-lab.de/doc/refT.html#text
> It's also useful to note that in short-circuit evaluation style
> functions like 'and, @ always holds the result of the previously
> evaluated argument, as you can see in this typical PicoLisp line:
> 
>   (and and (@ (min @ 5) (prinl @) (gt0 (dec @)) .))
> 
> ;)

hmm, went back to it and made it more elegant and efficient:
  
  (and 5 . ((prinl @) (gt0 (dec @)) .))

That should do ;) (TIL: how to write a list that curls into itself in
the middle)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: The many uses of @

2011-11-08 Thread José Romero
On Tue, 08 Nov 2011 21:47:04 +0100
Thorsten  wrote:

> José Romero 
> writes:
> 
> > 'text also uses @ http://software-lab.de/doc/refT.html#text
> > It's also useful to note that in short-circuit evaluation style
> > functions like 'and, @ always holds the result of the previously
> > evaluated argument, as you can see in this typical PicoLisp line:
> >
> >   (and and (@ (min @ 5) (prinl @) (gt0 (dec @)) .))
> >
> > ;)
> 
> ok, I added these two cases to the table (see below).
> 
> Could you give a little 'walk-through' for the example line, its not
> that obvious (to me) how this works (but it does) ;)
> 
> min, prinl, gt0 and dec are obvious.
> the double 'and and' and the '.' at the and are a bit strange. Where
> does the initial @=5 come from - because @ is initially T and T is
> greater than everything else?
> 
> cheers

Pretty silly and badly written explanation of what goes on there:

 I'm eval. I see a list, look inside, i see a symbol called 'and. i
 look at it's val. It's a number, thus a function pointer, i call it
 with the rest of the list unevaluated.

 I'm doAnd, i look at the list i was passed, i see a symbol called 'and,
 i evaluate it, a number came out, it's not NIL, so i shove it in @ and
 look at the next cadr. It's a list, i evaluate it, has a symbol called
 @ in it's car, that symbol resolves to a number, a pointer to doAnd, i 
 call it with the rest of the list unchanged.

 I'm doAnd, i look at the list i was passed, the first argument,
 evaluating it results in a function call that returns 5, it's not nil,
 so i shove it to @ and go on. The next element is another list, a call
 to prinl happens, it returned 5, it's not nil, so i shove it to @ and
 go on. Look at the next element, a call to (gt0 (dec @)), returns 4,
 that is not nil, so i shove the 4 in @ and go on. Looking at the next
 cadr i see @ again (but i don't realize, because i don't know wether a
 list is circular or not), it evaluates to 4, so i shove it to @ keep
 going. I see (min @ 5) again.
 ... 3
 ... 2
 ... 1
 ... (gt0 (dec @)) returns NIL here, so i stop evaluating and return NIL

 Back in the first doAnd, i see the previous call returned NIL, so i
 stop evaluating right there and return NIL.


Then I realized that it could be written with only one 'and using
the right syntax (and losing part of it's rube-goldberg appeal):

  (and 5 . ((prinl @) (gt0 (dec @)) .))

Cheers :3
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Wacky stuff with circular lists, Was:The many uses of @

2011-11-08 Thread José Romero
On Tue, 08 Nov 2011 23:14:59 +0100
Thorsten  wrote:

> José Romero 
> writes:
> 
> > On Tue, 08 Nov 2011 21:47:04 +0100
> > Thorsten  wrote:
> >
> >> José Romero 
> >> writes:
> >> 
> >> > 'text also uses @ http://software-lab.de/doc/refT.html#text
> >> > It's also useful to note that in short-circuit evaluation style
> >> > functions like 'and, @ always holds the result of the previously
> >> > evaluated argument, as you can see in this typical PicoLisp line:
> >> >
> >> >   (and and (@ (min @ 5) (prinl @) (gt0 (dec @)) .))
> >> >
> >> > ;)
> >> 
> >> ok, I added these two cases to the table (see below).
> >> 
> >> Could you give a little 'walk-through' for the example line, its
> >> not that obvious (to me) how this works (but it does) ;)
> >> 
> >> min, prinl, gt0 and dec are obvious.
> >> the double 'and and' and the '.' at the and are a bit strange.
> >> Where does the initial @=5 come from - because @ is initially T
> >> and T is greater than everything else?
> >> 
> >> cheers
> >
> > Pretty silly and badly written explanation of what goes on there:
> >
> >  I'm eval. I see a list, look inside, i see a symbol called 'and. i
> >  look at it's val. It's a number, thus a function pointer, i call it
> >  with the rest of the list unevaluated.
> >
> >  I'm doAnd, i look at the list i was passed, i see a symbol called
> > 'and, i evaluate it, a number came out, it's not NIL, so i shove it
> > in @ and look at the next cadr. It's a list, i evaluate it, has a
> > symbol called @ in it's car, that symbol resolves to a number, a
> > pointer to doAnd, i call it with the rest of the list unchanged.
> >
> >  I'm doAnd, i look at the list i was passed, the first argument,
> >  evaluating it results in a function call that returns 5, it's not
> > nil, so i shove it to @ and go on. The next element is another
> > list, a call to prinl happens, it returned 5, it's not nil, so i
> > shove it to @ and go on. Look at the next element, a call to (gt0
> > (dec @)), returns 4, that is not nil, so i shove the 4 in @ and go
> > on. Looking at the next cadr i see @ again (but i don't realize,
> > because i don't know wether a list is circular or not), it
> > evaluates to 4, so i shove it to @ keep going. I see (min @ 5)
> > again. ... 3
> >  ... 2
> >  ... 1
> >  ... (gt0 (dec @)) returns NIL here, so i stop evaluating and
> > return NIL
> >
> >  Back in the first doAnd, i see the previous call returned NIL, so i
> >  stop evaluating right there and return NIL.
> 
> great, thank you - thats probably what one would call "dense code". 
> 
> what I did not understand (or remembered) in the beginning was that
> symbols evaluate to their VAL, a number (the second 'and') and that a
> final '.' immediatly followed by a closing parenthesis indicates a
> circular list. 
> 
> a lot of things going on in one single line of code. in picolisp its
> really helpfull to be aware whats going on under the hood. 
> 
> > Then I realized that it could be written with only one 'and using
> > the right syntax (and losing part of it's rube-goldberg appeal):
> 
> that looks a bit easier ...
> 
> >   (and 5 . ((prinl @) (gt0 (dec @)) .))
> 
> let me try this one: 
> 
> I'm eval. I see a list, look inside, i see a symbol called 'and. i
> look at it's val. It's a number, thus a function pointer, i call it
> with the rest of the list unevaluated.
> I'm doAnd, i look at the number i was passed, i see a number 5,
> i evaluate it, a number came out, it's not NIL, so i shove it in @ and
> look at the next cadr. 
> 
> here I get stuck - this looks like a dotted pair cell, but thats a
> list and not an atom in the CDR? or is this list evaluated until it
> return an atom as an result? otherwise its clear that doAnd evaluates
> the circular list until NIL is returned.  
> 
> Cheers

If it helps, this is how that S-expression should look in memory, I
omitted the technically correct representation of numbers and symbols
to keep it simple:

 ,---,
+---+---+  +---+---+ '->+---+---+  +---+---+ |
|   | >| -->|   | >|   | '
+ | +---+  + | +---++ | +---+  + | +---+
  v  v| ,'
 and 5| |  +---+---+  +---+---+
  | '->|   | >|   | / |
  ,---'+ | +---+  + | +---+
  |  v  |
  | gt0 |  +---+---+  +---+---+
  | '->|   | >|   | / |
  |   +---+---+  +---+---+ + | +---+  + | +---+
  '-->|   | >|   | / |   v  v
  + | +---+  + | +---+  dec @
v  v
  prinl@

(I hope email keeps it's formatting)

Cheers
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PicoLisp is DEAD (Was: PicoLisp and its (lack of) libraries)

2012-01-22 Thread José Romero
On Sun, 22 Jan 2012 22:58:19 -0200
Jeronimo Pellegrini  wrote:

> You may count me as silent but very happy with PicoLisp!
> 
> I use it mostly for automating tasks in Unix systems (particularly
> fun in small devices running Linux).
> 
> J.
> 
> 
> On Sun, Jan 22, 2012 at 08:42:38AM +0100, Alexander Burger wrote:
> > OK, I understand.
> > 
> > The language is not useful or usable, and the "Community" (I count
> > 70 members in this list) is silent.
> > -- 
> > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

That's most of my use case too, Picolisp is a great language for
automation, it's simple I/O functions, with forks and pipes are just
great for interacting with old school Unix tools.

-- 
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
Looks like the example JSON functions choke on empty objects. I made a
quick and dirty fix, but I'm not sure if I introduced extra bugs.

Diff follows:
##
--- json.orig.l 2012-01-27 07:34:25.0 -0300
+++ json.l  2012-01-27 07:46:32.0 -0300
@@ -6,7 +6,7 @@
(case (read "_")
   ("{"
  (make
-(for (X (readJson)  T  (readJson))
+(for (X (readJson) (not (= "}" X)) (readJson))
(checkJson ":" (readJson))
(link (cons X (readJson)))
(T (= "}" (setq X (readJson
@@ -14,7 +14,7 @@
   ("["
  (make
 (link T)  # Array marker
-(for (X (readJson)  T  (readJson))
+(for (X (readJson) (not (= "]" X)) (readJson))
(link X)
(T (= "]" (setq X (readJson
(checkJson "," X) ) ) )
@@ -22,7 +22,7 @@
  
 (de printJson (Item)  # For simplicity, without indentation
(cond
-  ((atom Item) (print Item))
+  ((atom Item) (if Item (print @) (prin "{}")))
   ((=T (car Item))
  (prin "[")
  (map
##

Tested with this:
: (pipe (prinl "{\"one\":[[],[1,2,3],[],[]],\"two\":{}}") (readJson)) 
-> (("one" T (T) (T 1 2 3) (T) (T)) ("two"))
: (printJson @)  
{"one": [[], [1, 2, 3], [], []], "two": {}}-> "}"

If it's OK I'll edit the task page, buggy code is ugly code!

Cheers,
-José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
On Fri, 27 Jan 2012 12:55:29 +0100
Alexander Burger  wrote:

> Hi José,
> 
> > Looks like the example JSON functions choke on empty objects. I
> > made a
> 
> Oops. Right.
> 
> 
> > If it's OK I'll edit the task page, buggy code is ugly code!
> 
> Indeed. Please do so. Many thanks!

Done!

> 
> Cheers,
> - Alex

-José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
Hmmm, it still doesn't work quite well, it chokes on negative
numbers, no idea how to fix that. :(

-José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
On Fri, 27 Jan 2012 13:58:50 +0100
Alexander Burger  wrote:

> On Fri, Jan 27, 2012 at 01:48:41PM +0100, Alexander Burger wrote:
> > Let me check more thoroughly.
> 
> How about that?
> 
>(de readJson ()
>   (case (read "_")
>  ...
>  (T
> (let X @
>(if (and (= "-" X) (format (peek)))
>   (- (read))
>   X ) ) ) ) )

That seems to work for all my test cases, thanks! Changed it in the
Rosetta page too.

-José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (symbols) inside a function

2012-02-01 Thread José Romero
On Wed, 1 Feb 2012 05:53:11 -0800
Imran Rafique  wrote:

> Thanks for responding Alex.
> 
> As you know, I'm just trying out picolisp in my spare time (hence my
> slow responses on this list, sorry about that). To put some context
> to these questions, I thought that using seperate namespaces to
> simulate a key/value dictionary/hash-table would be a nice idea to
> play with, to understand picolisp better.
> 
> (alists are nice and easy, but if you update it frequently cons'ing
> changes to the begining, it gets slower & slower to work with the
> less frequently changing key/values at the end of the alist)
> 
Why not use a 'idx tree then? http://software-lab.de/doc/refI.html#idx

##
# I used 'name here to prevent accidental clobbering
(de iset (Tree Key Value)
   (set
  (or
 (car (idx Tree Key))
 (prog1 (name Key) (idx Tree @ T)) )
  Value ) )

(de iget (Tree Key)
   (val (car (idx Tree Key))) )

## Tests ##
: (iset 'mydict "Foo" 42)
-> 42

: (iset 'mydict "Bar" T)
-> T

: (iset 'mydict "Bam" "Baz")
-> "Baz"

: (iget 'mydict "Foo")
-> 42

: (iget 'mydict "Bam")
-> "Baz"

: (iget 'mydict "Bar")
-> T

: (mapcar show (idx 'mydict)) 
"Bam" "Baz"
"Bar" T
"Foo" 42
-> ("Bam" "Bar" "Foo")
###

> Anyway, as the symbol-table/namespace itself is just a big
> hash-table, then all we would need are: + a way to create a new
> namespace + check if a variable exists in that namespace + get or set
> a variable in that namespace
> 
[...]

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Canonical way to do master detail relationship.

2012-02-11 Thread José Romero
On Sun, 12 Feb 2012 16:16:26 +1100
Konrad Zielinski  wrote:

> Hi,
> 
> I'm trying to work out the proper way to setup a master detail
> relationship in a Picolisp database.
> 
> I have a master record with child records where each child record is a
> string and a number. Different master records do not at all care about
> each others details.
> And really The detail records will never be accessed outside the
> context of the master record. They don't need any indexing, or
> independent lookup.
> 
> so is this the way you would do this?
> 
> (class  +Child +Entity)
>  (rel description (+Key +String))
>  (rel rank (+Number))
> 
> (class +Master +Entity)
> (rel children (+List +Link) ord (+Child))
> 
> Also As master records don;t relate to each other I'm a little
> confused as to how I hand the rest of the database together.
> Do I just start it and add objects to it Or do  I need to build a top
> level List of master objects and set this as the first object
> in the database.
> 
> regards
> 
> Konrad
> 

Hmm, isn't this type of relationship covered by the +Ord and +Pos
classes in the example app included in picolisp's sources?

# @app/er.l
(class +Ord +Entity)
(rel nr (+Need +Key +Number))  # Order Number
[...]
(rel pos (+List +Joint) ord (+Pos))# Positions

(class +Pos +Entity)
(rel ord (+Dep +Joint) # Order
   (itm)
   pos (+Ord) )
[...]

Orders (masters) are keyed by the order number and +Pos "Order Items"
are linked to the order by a +Joint +List. 

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PicoLisp SSL Problem

2012-02-15 Thread José Romero
On Wed, 15 Feb 2012 08:00:10 +0100
Alexander Burger  wrote:

> Hi all,
> 
> since Firefox 10 (Windows) is out, some of my customers complain that
> they can't access their PicoLisp applications via SSL any longer. At
> least one also reports the same for Safari.
> 
> They can't access even the application's start page. The browser
> refuses to connect.
> 
> I've already generated new (self-signed) certificates, but this didn't
> help. Could it be 'httpGate'?
> 
> Does anybody have an idea? I can't reproduce the problem here, and the
> browser's error messages are not helpful at all.
> 
> The problem might be reproduced also on the demo app
> 
>https://app.7fach.de
> 
> or also on the Wiki
> 
>https://wiki.picolisp.com
> 
> though the latter is not covered by the certificate's Common Name (as
> it is for "*.7fach.de").
> 
> Why does this happen only with new browsers? I suspect something might
> be wrong with 'httpGate', though it worked during the last 10 years
> without problems.
> 
> Cheers,
> - Alex

I have checked both with FF10 and chromium and could see a problem in
both. In FF, it got an unhelpful "connection reset" error, while
chromium had me skipping the certificate twice before it worked. It all
points to a protocol error, either the browsers are now doing something
nonstandard or you cut some corner (or relied on something nonstandard
clients used to do) when you implemented the proxy originally and they
came back to haunt you.
Perhaps there is a light reverse proxy like tinyproxy or something like
that you could put in front of httpgate to temporarily solve the
problem by now?

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: android success with full picolisp

2012-02-20 Thread José Romero
On Mon, 20 Feb 2012 18:46:59 -0800 (PST)
Doug Snead  wrote:

> More android + picolisp fun, this time with the full picolisp.  Using
> the android SDK and NDK, I hacked a picolisp/src/makefile to work for
> android's arm processor like this: 
> 
> --- makefile ---
> [snip]
> 
> CFLAGS := -c -O2  -pipe \
>         -falign-functions=64 -fomit-frame-pointer
> -fno-strict-aliasing \ -W -Wimplicit -Wreturn-type -Wunused -Wformat \
>         -Wuninitialized -Wstrict-prototypes \
>         -D_GNU_SOURCE  -D_FILE_OFFSET_BITS=64
> # ?? had: -m32
> 
> NDK_ROOT = ~/android/android-ndk-r7
> NDK_BIN =
> $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
> SYS_ROOT = $(NDK_ROOT)/platforms/android-8/arch-arm/ CC =
> $(NDK_BIN)/arm-linux-androideabi-gcc --sysroot=$(SYS_ROOT) LD =
> $(NDK_BIN)/arm-linux-androideabi-ld AR =
> $(NDK_BIN)/arm-linux-androideabi-ar RANLIB =
> $(NDK_BIN)/arm-linux-androideabi-ranlib STRIP =
> $(NDK_BIN)/arm-linux-androideabi-strip
> 
>         OS = Arm
>         PICOLISP-FLAGS = -m32 -rdynamic
>         LIB-FLAGS = -lc -lm -ldl
>         DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic
> 
> [snip]
> -
> 
> Then (to my surprise) picolisp and dynamic libraries were made,
> 
> # file ../bin/picolisp  ../lib/ext  ../lib/ht ../lib/z3d  
> ../bin/picolisp: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
> dynamically linked (uses shared libs), stripped ../lib/ext:      ELF
> 32-bit LSB shared object, ARM, version 1 (SYSV), stripped ../lib/ht:
>      ELF 32-bit LSB shared object, ARM, version 1 (SYSV),
> stripped ../lib/z3d:      ELF 32-bit LSB shared object, ARM, version
> 1 (SYSV), stripped
> 
> So far so good...
> 
> Using this android approach generally,
> 
> http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App
> 
> I placed the picolisp executable in the assets dir and at run-time,
> copy it from assets to /data/data/ in the right place for that app.   
> 
> Since I'm using the emulator and I know where the executable was
> placed, I can run it using adb, for some command-line tests:
> 
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println
> "X")'  '-foo 123' -bye 123
> 
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (*
> "X" 2))'  '-foo 123' -bye 246
> 
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (*
> "X" 2))'  '-foo 12345' -bye 24690
> 
> A bit cumbersome having to unpack the executable and other files from
> the app's .apk (zip archive) to run it ... but it can be done.  And
> no fiddling with bits ... no changes to the (full picolisp) source at
> all.   
> 
> Next step is to try to similarly unpack all the libraries and see if
> a picolisp database server application can be run. Then more
> testing.  And use that with android's browser, all within an android
> app. 
> 
> But I'm very confident that the full picolisp will run on the android
> from what I see so far! 
> 
> There are ways to call java from C also, so that opens up
> possibilities of using android java libraries from android picolisp
> too. 
> 
> Cheers,
> 
> Doug
> 

Wow! that's awesome! I have always wanted to write a game for Android
but i dislike Java, I gotta give this a go when I have a bit more free
time.

Keep up the good work!
--José.
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Reference Example typo

2012-02-23 Thread José Romero
On Thu, 23 Feb 2012 16:16:01 -0500
Joe Bogner  wrote:

> Sidenote: Can someone explain why the use of the parentheses around
> the class name? It seems confusing to be '+Item in some contexts and
> '(+Item) in others.
> 
> 
It's the way typing works in the PicoLisp object system, "types" are
lists of prototype objects (or "mixin classes", whatever way you wanna
call them). When a message is sent to an object, be it with 'send 'try
or calling a method symbol (val=meth), the interpreter looks into the
val of the symbol for the method, if it's not there, it goes trough the
symbols at the tail of the list (the "type"), in order.

> Thanks!
> Joe
Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: returning multiple distinct closures

2012-02-23 Thread José Romero
On Fri, 24 Feb 2012 00:03:34 +
Imran Rafique  wrote:

> Picolisp'ers,
> 
> As the subject asks, is it possible to return multiple distinct
> closures from a single function? I was trying out a simple lazy lists
> implementation. The lazy function takes in something and returns that
> something wrapped in another function. If you want to 'force' the
> lazy value, you execute the wrapped function.
> 
> The closure is needed to ensure that when you force a value more than
> once, the wrapped function only gets executed the first time (and the
> cached value is used thereafter).
> 
> So:
> 
> (de lazy @Bdy
>   (fill
> '(job '((forced? . NIL)
> (value . "delayed"))
>(unless forced?
>  (setq value (eval (car '@Bdy)))
>  (setq forced? T))
>value)))
> 
> (de force (Lz)
>   (eval Lz))
> 
> Pretty simple stuff, but it doesn't work as intended. The closure
> returned by 'lazy' is the same job closure for ALL invocations of
> lazy.
> 
> (setq foo (lazy
> (prog
>   (prinl "!")
>   2)))
> 
> (setq bar (lazy
> (prog
>   (prinl "!!")
>   3)))
> 
> 
> pico λ: (force foo)
> !
> -> 2
> pico λ: (force foo)
> -> 2
> pico λ: (pretty bar)
> (job '((forced? . T) (value . 2))
>(unless forced?
>   (setq
>  value (eval (car '((prog (prinl "!!") 3 )
>   (setq forced? T) )
>value )-> ")"
> pico λ: (force bar)
> -> 2
> 
> Is this an artifact of how 'job' works, by rewriting the internal
> definition of the function which contains the call to job? How can
> one return distinct *different* closures from a single function?
> 
> Returning a properly formed anonymous function (as opposed to a 'job'
> form) doesn't make a difference:
> 
> (de lazy2 @Bdy
>   (fill
> '(()
>   (job '((forced? . NIL)
>  (value . "delayed"))
> (unless forced?
>   (setq value (eval (car '@Bdy)))
>   (setq forced? T))
> value
> 
> (de force2 (Lz)
>   (Lz))
> 
> --
> Regards,
>Imran Rafique

Your problem is using the quote function instead of making a copy of
the list on return, this rewritten version should work:

(de lazy Prg
   (list NIL
  (list 'job (list 'quote (cons 'Value "delayed"))
 (list 'if '(== Value "delayed")
(list 'setq 'Value (cons 'run Prg))
'Value ) ) ) )
()

(de force (Lz)
   (Lz) )

(setq foo (lazy
(prog
  (prinl "!")
  2)))

(setq bar (lazy
(prog
  (prinl "!!")
  3)))

: (pp 'foo)
(de foo NIL
   (job '((Value . "delayed"))
  (if (== Value "delayed")
 (setq Value (run (prog (prinl "!") 2)))
 Value ) ) )
-> foo
: (pp 'bar)
(de bar NIL
   (job '((Value . "delayed"))
  (if (== Value "delayed")
 (setq Value (run (prog (prinl "!!") 3)))
 Value ) ) )
-> bar

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: returning multiple distinct closures

2012-02-24 Thread José Romero
I've been thinking on the problem a bit and found another way to tackle
it, using this incredibly *UGLY* function (all of them formatted as
the output of 'pp, I have no idea how to make it more aesthetically
pleasing):

(de lazy Prg
   (let L (box (cons))
  (con
 (val L)
 (list
(list
   'cdar
   (list
  'con
  L
  (list
 'list
 (list 'cons ''quote (cons 'prog Prg)) ) ) ) ) )
  (val L) ) )
-> lazy
: (setq A (lazy (prinl "Computing...") 42))
-> (NIL (cdar (con $384526428 (list (cons 'quote (prog (prinl
"Computing...") 42)) 
: (A)
Computing...
-> 42
: (A)
-> 42
: A
-> (NIL '42)

As you can see, the resulting lambda modifies itself to become just the
quoted result on the first call. 

The way 'lazy works is by first boxing a cons pair to form the head of
the lambda expression. Then it concatenates a function body to that
head that is itself a call to 'con to replace itself with the computed
result in a quote. 

The box symbol is not necessary at all, I included it to make the
resulting expression printable. This version works the same, but
crashes print (rather, puts it in an infinite loop) if you use it in
the repl without a 'nil guard.

(de lazy Prg
   (let L (cons)
  (con
 L
 (list
(list
   'cdar
   (list
  'con
  (cons 'quote L)
  (list
 'list
 (list 'cons ''quote (cons 'prog Prg)) ) ) ) ) )
  L ) )
-> lazy
: (nil (setq A (lazy (prinl "Computing...") 42)))
-> NIL
: (A)
Computing...
-> 42
: (A)
-> 42
: A
-> (NIL '42)

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Bug in the wiki?

2012-02-28 Thread José Romero
On Tue, 28 Feb 2012 13:01:31 +0100
Alexander Burger  wrote:

> Hi Mansur,
> 
> > I've just installed fresh PL release and wiki from this link:
> > http://software-lab.de/wiki.tgz
> 
> OK, great.
> 
> 
> > When I'm logged in and navigate to "Role administration", I see this
> > error in the console:
> > 
> > [wiki/role.l:6] !? (idForm "Role" '(choRole) 'nm '+Role T '(may
> > ...
> > idForm -- Undefined
> 
> Yes, 'idForm' is a relatively new function, introduced with 3.0.9.3 or
> so. It is currently in Debian unstable, or in the latest testing
> release. Sorry for the inconvenience!
> 
> Cheers,
> - Alex

For these kinds of cases where it's not really that necessary to
upgrade picolisp for adding some minimal function I suggest a little
"idiom", a "standard" file, much like er.l, gui.l or lib.l called
"shim.l" that just has the copy&pasted functions that were added, or
monkey patches to others that were changed since the last "stable"
version you want to support (wrapped on conditional code on the value
returned by (version T), optionally quitting if the version is too
ancient to work at all), load it from main.l after the @lib/ modules. A
simple version check & quit is acceptable too. Something like

(unless (>= (version T) (3 0 9 3)) 
   (quit "Picolisp version 3.0.9.3 or higher is required"))

It should make "installation" of apps on places with global picolisps
more convenient.

My 2¢,
~José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Google Summer of Code (GSoC) 2012

2012-03-03 Thread José Romero
On Sat, 03 Mar 2012 21:10:25 +0100
Thorsten  wrote:

> Alexander Burger  writes:
> 
> Hi List,
> 
> > On Mon, Feb 27, 2012 at 01:40:16PM +0100, Thorsten wrote:
> >> We prepared a GSoC 2012 page in the PicoLisp wiki
> >> (http://picolisp.com/5000/!wiki?gsoc), where you can find more
> >> information. 
> >> ...
> >> For now (till 2012-03-09) the most important task is to collect
> >> ideas and find out who would like to be a mentor for his (or other
> >> peoples) project ideas. Then, if PicoLisp is accepted by Google,
> >> we need to spread the word and make students apply for a project.
> >> 
> >> Any thoughts or ideas how to make the PicoLisp application for the
> >> GSoC 2012 a success are welcome.
> 
> I would suggest to add at least 2 or 3 more project ideas to the ideas
> page (http://picolisp.com/5000/!wiki?ideasPage) to raise the odds of
> PicoLisp being accepted as mentoring organisation. 
> 
> The best case would be if anybody is interested to participate as a
> student and has a project idea (and a possible mentor in mind).
> However, if you would like to see some new feature in PicoLisp and to
> mentor the related project, it would be very helpfull too. 
> 
> A third (viable) option is to think about a project idea that is
> beneficial for the PicoLisp community and doesn't require special
> background (domain) knowledge from a (potential) mentor, but might be
> interesting for students in general. That way, you can propose an idea
> without being the student or mentor for that proposal. 
> 
> As an example, I would propose the project "Build a web-shop for
> PicoLisp". Would that make sense? Any other ideas?
> 
> If somebody has an idea but doesn't want to get involved with the
> wiki, he can just post it here on the list, I put it on the wiki
> then. 
> 
> Thanks

If I can make it to participate as a student I'd like to make a more
generic and portable web framework (in the sense of being able to deploy
it in more kinds of servers than a dedicated/VPS with permission to run
a server on a public port) Right now I have some work done in that
direction with my "scgi.l" simple framework that is capable of running
as a SCGI service, a CGI script and writing an HTTP backend it can also
run as a standalone server (or actually, any protocol that has a
CGI/HTTP-like interface can be adapted writing a backend) sharing most
of the code (I have some code for that but i haven't published it yet
because it's not complete/useful for anyone else than me at the
moment). 

I have a formed idea for the "low level" design of the framework, as
the internal protocol all backends "dump into" the app using a
consistent interface (a set of global variables and functions). 

If you are allowed to run persistent processes in your server you
would have at least these options for connecting the web application
to the web (or a caching reverse proxy).

 +---+++   +--+--++
 |   | <->|   Web  |<->| SCGI <> <>   |
 | I || Server |   +--+  <>   |
 | n |++  |  <>   |
 | t | ^  +-+   +-+  Common  <>  Web  |
 | e | '->| CGI |<->| PGI <> <>   |
 | r |+-+   +-+  Module  <>   Application |
 | n ||  <>   |
 | e | +--+  <>   |
 | t |<--->| HTTP <> <>   |
 |   | +-++
 +---+

The "PGI" (Picolisp Gateway Interface) backend is just thin glue to
allow a very simple CGI script to be able to "tunnel" a request to the
running picolisp server, to do it "properly" picolisp should be
provided with unix domain socket support so that it's not necessary
for the server to take a random high port and to ensure the same
privilege separation provided by the filesystem in the standard web
server setup (owners, users, chroots). The other backends are pretty
self explanatory, the functions defined in the common module should be
made in a way that the application can use special features in the
backend (for example X-Sendfile headers) falling back to emulating
them with picolisp for backends that do not support it.

If you are not allowed to run persistent processes you can still use
the framework (say, a very low traffic site, or you are just doing
tests on a shared host before investing on a bigger server) by
wrapping the whole thing around a CGI script, without changing any
more code downstream.

The things left to design is which would be the desirable feature set
the common module should have and how they should be implemented to
get the best efficiency and compatibility. So far I have implemented a
minimal feature set for some simple services I needed (right now
running with the GCI+PGI):

 - A simple url pattern based 

Re: Google Summer of Code (GSoC) 2012

2012-03-03 Thread José Romero
On Sat, 3 Mar 2012 17:56:06 -0500
Joe Bogner  wrote:

> Hi José -
> 
> I've been thoroughly impressed with everything I've seen from you and
> even more so if you're a student. Wow!
> 
> Related to your proposal below, if I can replay back what I am
> understanding, it sounds like there are three aspects to it:
> 
> 1.) A more robust interface between a web server and a picolisp app.
> Something that can work in a variety of situations (e.g.VPS or
> dedicated hosting).  This should enable more adoption of picolisp as a
> language for building web applicationss.
> 
> [Sidenote: I've used your SCGI.l with nginx with and it would benefit
> others to document how that could work]
> 
Yes exactly, a simple and "hackable" way to connect to most common web
server interfaces used nowadays.

> 2.) A routing framework (does this follow the REST framework
> discussions we've had on IRC?) to simplify web app development - again
> it seems like you are close here based on what I've seen in scgi.l
> 
Yes, by default I'd like to implement a simple RESTful resource
dispatcher, but it would be just the default, you can override the
handler earlier in the request and still benefit from the work done in
the "backends" while implementing some oddball URL schema in the most
comfortable way. That could be a quick and "simple" way to gradually
port the existing GUI framework to all those servers without rewriting
the whole app system to be restful.

> 3.) Provide some of the same functionality as XHTML without tying it
> to the session IDs. In other words, enable the general purpose GUI
> framework to be agnostic of the 'server' it's running in
> 
That too, I'd like to eliminate deep dependencies between modules, I'd
rather make a simple module that then can be easily "monkey patched" by
a more complex app than having it the other way around. I know that
hurts startup time, but unless you are using the "app as cgi script"
model it doesn't matter, and even then, it shouldn't be hard to
preprocess the sources to generate a more optimized "compiled" script,
the same way javascript files are being minified nowadays.

> I think these are all wonderful ideas. If I was sitting on the
> committee evaluating proposals for the GSoC I would be evaluating
> projects based on their ability to have a broad impact or solves an
> unsolved problem. Since picoLisp is fairly niche, I like that what
> you're suggesting could open it up to more developers. I am no expert
> in this area though. I am not sure how this would stand out against
> framework XYZ aiming for broader appeal.
> 
> I spent a minute looking for some more context on GSoC related to
> languages. I found a retrospective on haskell:
> http://www.gwern.net/Haskell%20Summer%20of%20Code
> 
> I guess for someone with no knowledge of picoLisp, as it relates to
> your proposal, why is picoLisp a good choice for web development? What
> would the successful completion of the proposal enable? I have some
> perspective but would be interested in hearing what you think.
> 
One thing I love about picolisp is it's interactivity, I can interact
with a running app using the repl (and the wonderful 'edit function).
The equivalence of code and data and dynamic binding help a lot to
alter the system as it's running to try out new things with a very
quick turnaround time. And still, despite the great flexibility it also
offers very competitive speed if you compare it to other common
languages used for the web. The whole system is also simple enough to
be able to learn deep stuff about it's internals and code minding them
instead of treating it like a black box behind a truckload of specs.

Other very positive point for picolisp is it's code compactness, the
built in functions are simple building blocks that can achieve really
powerful and diverse behaviors combining them in clever ways, much like
the UNIX core utils. 

Another relevant good point for picolisp used in this scenario is it's
database system. Sadly it's not as well documented as it deserves, but
every day I find out new things about it. (Documenting it would be a
great project, but GSoC favors code over documentation, sadly.)

> Thanks for sharing it!
> Joe
> 
> [snipped bottom post]

-José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Construct sequences of URL-Strings - need help

2012-03-04 Thread José Romero
On Mon, 05 Mar 2012 03:37:35 +0100
Thorsten  wrote:

> 
> 
> Hi List, 
> 
> I try to construct sequences of URL-Strings separated by one blank and
> have been almost successfull - but I have to get rid of all the
> backslashes '\' in the string sequence:
> 
> Here is the 'workhorse-function' for the task: 
> 
> ,-
> | ### construct the url's
> | (de replaceUrlWildcard (U W)
> | (let Y (split (chop U) "*")
> |(glue "\" \"" (mapcar '((X) (pack (car Y) X  (cdr Y))) W)) ))
> `-
> 
> And here is the use case:
> 
> ,-
> | ### define the url's 
> | (setq U_ref # URL 
> |"http://software-lab.de/doc/ref*.html"; )
> | (setq W_ref  # wildcard replacements
> |(list "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N"
> "O" "P" |"Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" ))
> | 
> | ### make a sequence of url strings 
> | (setq UrlStrings_ref (pack  (replaceUrlWildcard U_ref W_ref)
> ))
> `-
> 
> Thats what I get (strings seperated by one blank - with backslashes):
> 
> ,---
> |  ? (pack  (replaceUrlWildcard U_ref W_ref) )
> |  
> | "http://software-lab.de/doc/refA.html\";
> | \"http://software-lab.de/doc/refB.html\";
> | \"http://software-lab.de/doc/refC.html\";
> | \"http://software-lab.de/doc/refD.html\";
> | \"http://software-lab.de/doc/refE.html\";
> | \"http://software-lab.de/doc/refF.html\";
> | \"http://software-lab.de/doc/refG.html\";
> | \"http://software-lab.de/doc/refH.html\";
> | \"http://software-lab.de/doc/refI.html\";
> | \"http://software-lab.de/doc/refJ.html\";
> | \"http://software-lab.de/doc/refK.html\";
> | \"http://software-lab.de/doc/refL.html\";
> | \"http://software-lab.de/doc/refM.html\";
> | \"http://software-lab.de/doc/refN.html\";
> | \"http://software-lab.de/doc/refO.html\";
> | \"http://software-lab.de/doc/refP.html\";
> | \"http://software-lab.de/doc/refQ.html\";
> | \"http://software-lab.de/doc/refR.html\";
> | \"http://software-lab.de/doc/refS.html\";
> | \"http://software-lab.de/doc/refT.html\";
> | \"http://software-lab.de/doc/refU.html\";
> | \"http://software-lab.de/doc/refV.html\";
> | \"http://software-lab.de/doc/refW.html\";
> | \"http://software-lab.de/doc/refX.html\";
> | \"http://software-lab.de/doc/refY.html\";
> | \"http://software-lab.de/doc/refZ.html";
> `---
> 
> This is what I would need (strings separated by one blank,  no '\'):
> 
> ,---
> | "http://software-lab.de/doc/refA.html";
> | "http://software-lab.de/doc/refB.html";
> | "http://software-lab.de/doc/refC.html";
> | "http://software-lab.de/doc/refD.html";
> | "http://software-lab.de/doc/refE.html";
> | "http://software-lab.de/doc/refF.html";
> | "http://software-lab.de/doc/refG.html";
> | "http://software-lab.de/doc/refH.html";
> | "http://software-lab.de/doc/refI.html";
> | "http://software-lab.de/doc/refJ.html";
> | "http://software-lab.de/doc/refK.html";
> | "http://software-lab.de/doc/refL.html";
> | "http://software-lab.de/doc/refM.html";
> | "http://software-lab.de/doc/refN.html";
> | "http://software-lab.de/doc/refO.html";
> | "http://software-lab.de/doc/refP.html";
> | "http://software-lab.de/doc/refQ.html";
> | "http://software-lab.de/doc/refR.html";
> | "http://software-lab.de/doc/refS.html";
> | "http://software-lab.de/doc/refT.html";
> | "http://software-lab.de/doc/refU.html";
> | "http://software-lab.de/doc/refV.html";
> | "http://software-lab.de/doc/refW.html";
> | "http://software-lab.de/doc/refX.html";
> | "http://software-lab.de/doc/refY.html";
> | "http://software-lab.de/doc/refZ.html";
> `---
> 
> I could of course use query-replace in Emacs and delete the
> backslashes, but I would like to have a correctly formated sequence
> of URL strings as output: 
> 
> ,-
> | "url-sting1" "url-string2" ... "url-stringN"
> `-
> 
> Any tips would be appreciated
> TIA
> 

Huh? i don't see any backslashes, you are missing the quotes at the
start and end though. This is the "correct" code, if my mind reading
skills are working well today:

: (prin "\"" (replaceUrlWildcard U_ref W_ref) "\"")
"http://software-lab.de/doc/refA.html";
"http://software-lab.de/doc/refB.html";
"http://software-lab.de/doc/refC.html";
"http://software-lab.de/doc/refD.html";
"http://software-lab.de/doc/refE.html";
"http://software-lab.de/doc/refF.html";
"http://software-lab.de/doc/refG.html";
"http://software-lab.de/doc/refH.html";
"http://software-lab.de/doc/refI.html";
"http://software-lab.de/doc/refJ.html";
"http://software-lab.de/doc/refK.html";
"http://software-lab.de

Re: Structuring a GUI project to avoid stop - starts

2012-03-05 Thread José Romero
Hi Konrad,

On Tue, 6 Mar 2012 12:46:44 +1100
Konrad Zielinski  wrote:

> Hi,
> 
> At the moment I have my project in two files
> 
> model.l which contains my domain classes, database init code and other
> related functions.
> server.l which contains my URL handling functions.
> 
> I find that I'm constantly having to kill and restart the server
> process and then navigate to the code I'm working on. This is quite
> cumbersome.
> 
> Is there a way to get the running picolisp process to detect and
> action changed source files without constant restarts.
> 
> regs Konrad
> 

You could just use the technique Alex uses, most of the code that
may need some quick tweak for each object is contained in a file that
is quickly 'loaded every time a request for that object arrives.

If you are careful designing the application you could make server.l
'load model.l again once in a while (maybe by "visiting" some secret
URL). if you have stuff in server.l that may change very often, move it
out to another module.

If you want to automatically detect a changed file and reload it, you
could code something like this, on Linux, using inotifywait(1) (I use
this code for synchronizing files between my shared host and my laptop
over ssh+rsync)

# Recursively watch the current directory 
(setq *InotifyFD
   (pipe
  (call 'inotifywait "-mrq"
 "-e" "modify,create,move,delete"
 "." ) ) ) 

(de reload ()
   # load modules, initialize variables, etc etc.
 )

(task *InotifyFD
   (in *InotifyFD
  # The process died somehow, clean up.
  (when (eof) (task *InotifyFD))
  (line) # Eat notification.
  # Wait 5 secs for the notifications to settle before reloading.
  (alarm 5 (reload)) ) )

You could be more sophisticated reading the module name of the file
that changed, or preferably being more specific with which files to
watch, look at the manpage of inotifywait(1) for loads of more useful
info.

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Subscribe

2012-04-01 Thread José Romero
Hello =?UTF-8?B?Sm9zw6k=?= Romero  :-)
You are now subscribed


-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Unsubscribe

2012-04-01 Thread José Romero
Good bye =?UTF-8?B?Sm9zw6k=?= Romero  :-(
You are now unsubscribed


-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Speedtest PicoLisp vs Emacs Lisp

2012-04-22 Thread José Romero
On Mon, 23 Apr 2012 02:22:21 +0200
Thorsten  wrote:

> 
> Hi List, 
> out of curiosity I did a little speedtest with PicoLisp and Emacs Lisp
> on a 64bit Arch Linux (see
> http://picolisp.com/46850/62704437697738713~!wiki?PILvsEL). 
> 
> The results are quite favorable for PicoLisp - it is about 4 times
> faster than interpreted Emacs Lisp and 2 times faster than compiled
> Emacs Lisp.
> 

Nice, I did my own tests on a 32 bit machine, not such a dramatic
speedup for picolisp by my numbers (about the same speed as bytecode)
but this thing is only really measuring function call/arithmetic cost.

$ cat > fibo.el << .
> (defun fibo (N)
>(if (> 2 N)
>   1
>   (+ (fibo (1- N)) (fibo (- N 2))) ) )
> 
> (fibo 35)
> .
$ time emacs --no-site-file --script fibo.el 

real0m13.854s
user0m13.829s
sys 0m0.016s
$ emacs --no-site-file -batch -f batch-byte-compile fibo.el 
Wrote /home/cyborgar/tmp/sptest/fibo.elc
$ time emacs --no-site-file --script fibo.elc

real0m5.882s
user0m5.828s
sys 0m0.008s
$ cat > fibo.l << .
> (de fibo (N)
>(if (> 2 N)
>   1
>   (+ (fibo (dec N)) (fibo (- N 2))) ) )
> (fibo 35)
> .
$ time pil fibo.l -bye

real0m5.662s
user0m5.624s
sys 0m0.004s

I tested with the "extensive list manipulations" code Alex tested CLisp
and SBCL a while back, with pretty nice results also:

$ cat > tst.el << .
> (defun tst ()
>   (mapcar
>(lambda (X)
>   (cons
>(car X)
>(reverse (delete (car X) (cdr X))) ) )
>'((a b c a b c) (b c d b c d) (c d e c d e) (d e f d e f)) ) )
> (dotimes (i 100) (tst))
> .
$ time emacs --no-site-file --script tst.el 

real0m8.311s
user0m8.273s
sys 0m0.032s
$ emacs --no-site-file -batch -f
batch-byte-compile tst.el Wrote /home/cyborgar/tmp/sptest/tst.elc
$ time emacs --no-site-file --script tst.elc 

real0m5.622s
user0m5.604s
sys 0m0.012s
$ cat > tst.l << .
> (de tst ()
>(mapcar
>   '((X)
> (cons
>(car X)
>(reverse (delete (car X) (cdr X))) ) )
>   '((a b c a b c) (b c d b c d) (c d e c d e) (d e f d e f)) ) )
> (do 100 (tst))
> .
$ time pil tst.l -bye

real0m1.208s
user0m1.192s
sys 0m0.012s

Looks like the emacs compiler can't improve much in that function and
it's still 4.6-6.9x slower than picolisp, whoops :)

$ uname -a
Linux icz 2.6.32-5-686 #1 SMP Mon Jan 16 16:04:25 UTC 2012 i686
GNU/Linux 
$ cat /proc/cpuinfo |grep "model name" | cut -d: -f2
 Pentium(R) Dual-Core CPU   T4200  @ 2.00GHz
 Pentium(R) Dual-Core CPU   T4200  @ 2.00GHz

Cheers, 
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Websockets

2012-05-27 Thread José Romero
On Sun, 27 May 2012 18:53:31 +0700
Henrik Sarvell  wrote:

> Google couldn't show me any prior discussions of websockets and
> picolisp.
> 
> Is it too early to start thinking about this maybe, seems like the
> spec/ref is still changing a little bit too fast/much atm?
> 
> http://en.wikipedia.org/wiki/WebSocket
> 
> http://tools.ietf.org/html/rfc6455
> 
> C lib: http://git.warmcat.com/cgi-bin/cgit/libwebsockets/
> 
> It came up today when I started to think about how crude file uploads
> via http is with no way of knowing the progress, but they can be used
> for much much more than fancy uploading interfaces of course.
> 
> Having looked a bit at the ref ( http://tools.ietf.org/html/rfc6455 )
> it seems to me that it looks quite straight forward.
> 
> The question is, what is easier/more efficient, implementing this from
> scratch or with the help of the C lib and native? That is the question
> that maybe someone more experienced in C/in general than me can
> answer?

I guess i should have posted this here before:
https://bitbucket.org/cyborgar/web.l/src/249fe9f5c7d8/web/sockets.l

That implements the RFC almost completely (there's no much
implementation of the error code thingamajig because actually browsers
don't even implement ping/pong correctly yet!). The implementation is
in pure lisp, but it could be accelerated with a C library (actually
the only thing to accelerate is the xor descrambling, could be done in
an 'in-like environment). The webtest.l in the root of the repo provides
a (ugly) chat server example using my web.l framework. Sorry if the code
is not very elegant but I didn't devote that much time to that example.

Here's the documentation of that module:
https://bitbucket.org/cyborgar/web.l/wiki/Sockets

Also, the spec is pretty much set in stone, at least as far as the IETF
is concerned, RFC 6455 is a standards track document.

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Parallel command execution

2012-05-28 Thread José Romero
On Mon, 28 May 2012 23:51:21 +0200
Jorge Acereda  wrote:

> Hi,
> 
> I need to invoke external commands for each entry in my database and
> I want to run those in parallel, but restricting the number of
> simultaneous jobs to a certain number to avoid bringing the machine
> to its knees (sort of 'make -jN').
> 
> How would you approach such problem?
> 
First a bit more of information is needed, what do you need to
parallelize? The processing steps within each entry, or the processing
of the entries themselves? Are there any dependencies that should be
taken into account?

> Thanks,
>   Jorge
> 

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


[WIP] Patch: Unix domain socket support for pil32

2012-09-01 Thread José Romero
I tried to give adding support for Unix domain sockets in pil a go, but
I couldn't make functional code yet because I don't really grasp
completely how the macro beast language pil32 is written in works (I
wrote all the docs though). 

The changes would be basically to add a function called 'sock, which
will create a Unix socket at a given path, and modify 'connect and 'udp
to accept a Unix socket path in the position of the port/service if the
given host name is NIL.

The patch should be attached to this message, if it isn't I pasted a
copy here: http://2.71828.com.ar/p/c;QYLoXQ

I'd thank any help to get those functions working as I intend.

Cheers,
José
diff -r 425552fd43a8 doc/refA.html
--- a/doc/refA.html	Fri Aug 03 09:10:32 2012 +0200
+++ b/doc/refA.html	Sat Sep 01 16:58:35 2012 -0300
@@ -129,7 +129,8 @@
 
 (accept 'cnt) -> cnt | NIL
 Accepts a connection on descriptor cnt (as received by port), and returns the new socket descriptor
+href="refP.html#port">port or sock), and returns the new socket descriptor
 cnt. The global variable *Adr is set to the IP address
 of the client. See also listen,
 connect and  2
 
 
-(connect 'any1 'any2) -> cnt | NIL
+(connect ['any1|'NIL] 'any2) -> cnt | NIL
 Tries to establish a TCP/IP connection to a server listening at host
 any1, port any2. any1 may be either a
 hostname or a standard internet address in numbers-and-dots/colons notation
 (IPv4/IPv6). any2 may be either a port number or a service name.
 Returns a socket descriptor cnt, or NIL if the
-connection cannot be established. See also listen and udp.
+connection cannot be established. If the first argument
+is NIL, then it attempts to establish the connection with
+a unix domain socket located in any2. See
+also listen
+and udp.
 
 
 : (connect "localhost" )
 -> 3
 : (connect "some.host.org" "http")
 -> 4
+: (connect NIL (pil "foo.sock"))
+-> 5
 
 
 (cons 'any ['any ..]) -> lst
diff -r 425552fd43a8 doc/refL.html
--- a/doc/refL.html	Fri Aug 03 09:10:32 2012 +0200
+++ b/doc/refL.html	Sat Sep 01 16:58:35 2012 -0300
@@ -361,7 +361,9 @@
 
 (listen 'cnt1 ['cnt2]) -> cnt | NIL
 Listens at a socket descriptor cnt1 (as received by port) for an incoming connection, and returns
+href="refP.html#port">port
+or sock) for an incoming
+connection, and returns
 the new socket descriptor cnt. While waiting for a connection, a
 select system call is executed for all file descriptors and timers
 in the VAL of the global variable  "a"
 
 
+(sock ['T] 'any) -> cnt
+Opens a TCP Unix domain socket at the path any (or a
+UDP socket if the first argument is T), and returns a
+socket descriptor suitable as an argument
+for listen
+or accept
+(or udp, respectively).
+
+
+: (sock (pil "foo.sock"))   # Open a socket in ~/.pil/foo.sock
+-> 4
+
+
 (solve 'lst [. prg]) -> lst
 Evaluates a Pilog query and, returns the list
 of result sets. If prg is given, it is executed for each result
diff -r 425552fd43a8 doc/refU.html
--- a/doc/refU.html	Fri Aug 03 09:10:32 2012 +0200
+++ b/doc/refU.html	Sat Sep 01 16:58:35 2012 -0300
@@ -93,15 +93,18 @@
 -> T
 
 
-(udp 'any1 'any2 'any3) -> any
+(udp ['any1|'NIL] 'any2 'any3) -> any
 (udp 'cnt) -> any
 Simple unidirectional sending/receiving of UDP packets. In the first form,
 any3 is sent to a UDP server listening at host any1,
-port any2. In the second form, one item is received from a UDP
-socket cnt, established with port. See also listen and connect.
+port any2. If the first parameter is NIL,
+the data will be sent to a unix socket located
+in any2. In the second form, one item is received from a
+UDP socket cnt, established
+with port
+or sock. See
+also listen
+and connect.
 
 
 # First session
diff -r 425552fd43a8 src/net.c
--- a/src/net.c	Fri Aug 03 09:10:32 2012 +0200
+++ b/src/net.c	Sat Sep 01 16:58:35 2012 -0300
@@ -62,6 +62,31 @@
return boxCnt(sd);
 }
 
+// (sock ['T] 'any) -> cnt
+any doSock(any ex) {
+   any x, y;
+   int type, sd, n;
+   unsigned short port;
+   char* nm;
+   struct sockaddr_un addr;
+   x = cdr(ex);
+   type = SOCK_STREAM;
+   if ((y = EVAL(car(x))) == T)
+	   type = SOCK_DGRAM,  x = cdr(x),  y = EVAL(car(x));
+   if ((sd = socket(AF_UNIX, type, 0)) < 0)
+	   ipErr(ex, "socket");
+   closeOnExec(ex, sd);
+   memset(&addr, 0, sizeof(addr));
+   addr.sun_family = AF_UNIX;
+   // nm = /* A WAY TO GET THE PARAM'S SYMBOL NAME */ 
+   strncpy(addr.sun_path, nm, sizeof(addr.sun_path)-1);
+   if (bind(sd, (struct sockaddr*)&addr, sizeof(addr)) < 0)
+	   close(sd),  ipErr(ex, "bind");
+   if (type == SOCK_STREAM  &&  listen(sd,5) < 0)
+	   close(sd),  ipErr(ex, "listen");
+   return boxCnt(sd);
+}
+
 static any tcpAccept(int sd) {
int i, f, sd2;
char s[INET6_ADDRSTRLEN];
@@ -139,13 +164,13 @@
return getaddrinfo(nd, sv, &hints, &lst)? NULL : lst;
 }
 
-// (connect 'any1 'any2) -> cnt | NIL
+// (connect ['any1|'NIL] 'any2) -> cnt | NIL
 any doConnect(any ex) {
struct addrinfo *lst, *p;
any port;
int sd;
cell c1;
-
+   /* MAKE IT SO IF FIRST PA

GOTO in PicoLisp

2012-09-05 Thread José Romero
Because the world wasn't weird enough already I took the liberty to
implement goto in picolisp. This works by using a "trampoline" based on
'throw and 'catch, each goto makes the evaluation "bounce" and continue
from the point of the next label until it falls trough.

(de goto (L)
   (throw 'goto L) )

(de prog+ "Prg"
   (use ("Thunk" "Ret" "L")
  (setq "Thunk" "Prg" "Ret" NIL)
  (while
 (catch 'goto
(setq "Ret" (run "Thunk")) )
 (setq "L" @
"Thunk" (seek '[(X) (= (car X) "L")] "Prg") ) )
  "Ret") )
()

Labels should be atoms (though they can be anything that can be
compared with = and would have no side effect when evaluated.)

A couple examples:

Nested loop:

(prog+
   (zero I J)
 loop:
   (prinl I "," J)
   (when (< (inc 'I) 4)
  (goto 'loop:) )
   (when (< (inc 'J) 4)
  (zero I)
  (goto 'loop:) ) ) 

Infinite loop:

(prog+
   10 (prinl "cyborg_ar is a genius!")
   20 (goto 10) )

"Computed" goto:

(prog+
   (goto 'ask:)
 err:
   (prinl "^JSorry, i quite didn't get that...")
 ask:
   (prinl "Choose a number from 0-3:")
   (goto (or (min (format (line)) 4) 'err:))
 0 (prinl "You chose zero.") (goto 'end:)
 1 (prinl "You chose one.") (goto 'end:)
 2 # Fall trough 
 3 (prinl "You chose two or three.") (goto 'end:)
 4 (goto 'err:)
 end:
   (prinl "Bye!") )

Cheers,
José

PS: I leave the implementation of COMEFROM as an exercise for the
reader.
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-05 Thread José Romero
On Thu, 6 Sep 2012 08:01:28 +0200
Alexander Burger  wrote:

> Hi Laurent,
> 
> back to your original mail:
> 
> > By the way, if anyone know what lib to use for (native) to make a
> > lstat syscall so I can replace the stat shell call, I'd be very
> > grateful: I can't find where it is! (contrary to what I thought, it
> > is NOT in libc...)
> 
> It seems the internal symbol is '__xstat'.
> 
> >From "/usr/include/x86_64-linux-gnu/sys/stat.h":
> 
>__extern_inline int
>__NTH (stat (__const char *__path, struct stat *__statbuf))
>{
>  return __xstat (_STAT_VER, __path, __statbuf);
>}
> 
> That's a pity, because it makes it rather unportable.
> 
> 
> 
> BTW, instead of using 'line', 'split' and 'pack' in
> 
> > (de stat (Path)
> >(mapcar pack
> >   (split
> >  (in
> > (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
> > (line) )
> >  " " ) ) )
> 
> and later parsing it with 'hex' and 'format', you could read it
> directly:
> 
> (in (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
>(make
>   (link (hex (till " "))
>   (do 8
>  (link (read)) ) ) ) ) 
> 
Why not just:

(in (list "stat" "-c" "(`(hex \"%f\") %s %u %g %h %i %X %Y %Z)" Path)
   (read) ) 

:D

> Cheers,
> - Alex

Cheers,
- José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: GOTO in PicoLisp

2012-09-07 Thread José Romero
On Fri, 7 Sep 2012 07:51:03 +0200
Alexander Burger  wrote:

> Hi José,
> 
> > Because the world wasn't weird enough already I took the liberty to
> 
> Bravo! That's a valid idea ;)
> 
> 
> Let me suggest two small changes:
> 
> > (de prog+ "Prg"
> >(use ("Thunk" "Ret" "L")
> >   (setq "Thunk" "Prg" "Ret" NIL)
> >   (while
> 
> Did you have any special reason for 'use'? Otherwise I would use
> 'let':
> 
> (de prog+ "Prg"
>(let ("Thunk" "Prg"  "Ret" NIL  "L" NIL)
>   (while
> 
> 
> The call to 'seek'
> 
> >(seek '[(X) (= (car X) "L")] "Prg")
> 
> can in this case be replaced by member:
> 
>(member "L" "Prg")
> 
> Cheers,
> - Alex

I "picolisped" a bit the functions and came up with this:

(de prog+ "Prg"
   (let ("Thunk" "Prg" "Ret" NIL "L" NIL)
  (while (setq "Thunk" (catch 'goto (setq "Ret" (run "Thunk")
  "Ret" ) )

(de goto (L)
   # "Prg" from 'prog+
   (throw 'goto (member L "Prg")) )

()

Now goto throws the thunk itself, passing it as a continuation. You can
manually throw any code (even code generated on the fly).

I wonder if there is an use case where this could be actually faster
than other alternatives.

Cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: `rd' behavior

2012-11-05 Thread José Romero
On Mon, 05 Nov 2012 14:37:07 +0100
dexen deVries  wrote:

> hello list,
> 
> why does `rd' return NIL in simplest use ('sym or NIL argument):
> (in "info.txt"
>(print (rd]
> 
> while it seems to work fine with 'cnt argument:
> (in "info.txt"
>(print (rd 1]
> 
> guess i'm doing something wrong @_@
> 
> using picoLisp-3.1.0.tgz.
> 

rd without argument (or with a sym) means binary read, it tries to read
an atom or expression in the binary PLIO format (used by pr). Rd with a
number argument means to read the given amount of bytes as a bignum.
The sym argument is an optional end of file flag to return instead of
the default (NIL).
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: `rd' behavior

2012-11-05 Thread José Romero
On Mon, 05 Nov 2012 15:29:42 +0100
dexen deVries  wrote:

> On Monday 05 of November 2012 10:54:20 you wrote:
> > rd without argument (or with a sym) means binary read, it tries to
> > read an atom or expression in the binary PLIO format (used by pr).
> > Rd with a number argument means to read the given amount of bytes
> > as a bignum. The sym argument is an optional end of file flag to
> > return instead of the default (NIL).
> 
> 
> thanks, i get it now :-)
> 
> inspired by recent post on HN, i want to learn picoLisp (at last :P)
> by re- implementing some basic UNIX tools. here goes the venerable
> cat:
> 
> #!/usr/bin/env plmod
> 
> (mapcar '(
>   (file)
> 
>   (in file
>   (use X
>   (until (== NIL
>   (setq X (rd 1)) )
>   (wr X) ) ) ) )
> 
>   (argv))
> 
> (bye)
> 
> 
> guess it could be shorter...
> 
Maybe this?

   (while (opt) (in @ (echo)))

Though it doesn't really handle well pipelines (if something
downstream dies it doesn't seem to die properly like cat does).

> 
> cheers,

cheers,
José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Normalize PicoLisp Wiki Syntax

2012-11-24 Thread José Romero
On Sat, 24 Nov 2012 17:29:13 +0100
Thorsten Jolitz  wrote:

> 
> Hi List, 
> 
> when writing the picolisp-wiki-mode for Emacs, I began to understand
> why mark-up syntax is usually symmetric, i.e. the end-tag looks like a
> 180° mapping of the start-tag (e.g. the JSP Scriplet <% ... %>). 
> 
> This makes parsing the file and constructing regexp much easier,
> because its always clear which end-tag belongs to which start-tag. 
> 
> The PicoLisp Wiki Syntax does not follow this convention:
> 
>,---
>| 3{Heading} Heading (level 3)
>|Levels 1 .. 6 are allowed
>| 
>| &{3}   Insert 3 line breaks
>| &{-3}  Insert 3 line breaks, clear float
> style | 
>| /{italic}  Italic font
>| !{bold}Bold font
>| _{underline}   Underlined font  [...]
>`---
> 
> Considering the possible nesting of elements (e.g. a bold word inside
> a link inside a list item), it becomes very difficult to construct
> regexp that reliably identify elements (necesary for fontification)
> because there are so many closing braces '}' around (and there might
> even be closing braces in the text itself).
> 
> What about changing the syntax to this:
> 
>,---
>| 3{Heading}3 Heading (level 3)
>|Levels 1 .. 6 are allowed
>| 
>| &{3}&   Insert 3 line breaks
>| &{-3}&  Insert 3 line breaks, clear float
> style | 
>| /{italic}/  Italic font
>| !{bold}!Bold font
>| _{underline}_   Underlined font  [...]
>`---
>  
> I know, its one more char to type (not when you use the
> picolisp-wiki-mode for Emacs) and looks ugly, but would make things a
> bit more 'standard' and easier to deal with. Its not really a big
> issue, since the picolisp-wiki-mode works fine even if fontification
> is a bit random. Don't know if it would be an improvement and worth
> the pain. 
> 

It's not an improvement, and not worth it, imo. The current wiki syntax
is pretty much a lightweight variant of TeX, Emacs can fontify TeX just
fine, so the issue is in the emacs mode, not the syntax.

-Jose
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe