Re: A couple of corrections and questions on documentation

2022-06-27 Thread Karl-Heinz Kreis

Epub is basically a zipped directory with html, css and media files.
The html easyly flows according to differrent page sizes, but some
elements, as  or , need non-standard styling, else they
break out of right border of page. That overflow isn't visible. Images
also need some attention, to make them fit on the visible page, i use
as '.css' something like:

img { max-width:100%;
height: auto;
}

Files of other types, like .txt or office suites, need to be converted,
to bee visible.

Greetings , Karl-Heinz


pgpNPgZ9TBgbA.pgp
Description: Digitale Signatur von OpenPGP


Re: A couple of corrections and questions on documentation

2022-06-26 Thread Alexander Burger
Hi Christos,

> Because I sometimes prefer reading from paper instead of electronically, I
> am currently compiling some of the PicoLisp official documentation and
> typesetting a small book in order to print it for myself.

OK


> First, I want to propose the following two small corrections:
> ...
> the word Argumnets instead of Arguments.
> ...
> any.

Very good, thank you! I fixed them.


> Then, I would like to ask whether the following two articles:
> - https://software-lab.de/doc64/asm
> - https://software-lab.de/doc64/structures
> are still actual, or perhaps they no longer reflect how PicoLisp works
> after switching to LLVM? I only ask because they seem older than pil21.

Right, they are obsolete now. They are not in the Pil21 release, instead there
is a new @doc/structures file. I have now also put it on

   https://software-lab.de/doc/structures


> I have uploaded the scripts to compile and typeset the book here
> https://gitlab.com/cgitsis/book-of-picolisp, in case someone is interested
> in them.

Good to know. Thanks a lot!

☺/ A!ex

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


A couple of corrections and questions on documentation

2022-06-26 Thread Christos Gitsis
Hello,

Because I sometimes prefer reading from paper instead of electronically, I
am currently compiling some of the PicoLisp official documentation and
typesetting a small book in order to print it for myself.

First, I want to propose the following two small corrections:
- In the file https://software-lab.de/doc/ref.html I find an instance of
the word Argumnets instead of Arguments.
- In the file refA.html in the definition of the function all* I find:
any. The closing tag should be changed to , else this
seems to mess up the whole page https://software-lab.de/docare/refA.html
 from that point until the end in my
browser (all text appears monospaced and formatted as code).

Then, I would like to ask whether the following two articles:
- https://software-lab.de/doc64/asm
- https://software-lab.de/doc64/structures
are still actual, or perhaps they no longer reflect how PicoLisp works
after switching to LLVM? I only ask because they seem older than pil21.

I have uploaded the scripts to compile and typeset the book here
https://gitlab.com/cgitsis/book-of-picolisp, in case someone is interested
in them.

Regards,
Christos Gitsis


Re: some questions relating pilog

2022-02-15 Thread Alexander Burger
On Tue, Feb 15, 2022 at 06:34:58PM +0100, pd wrote:
> > It tries the first one but does not succeed. The second one matches, so the
> > others are not tried because of the cut.
> 
> This is interesting, in my understanding when matching the first rule it
> should try to unify @C to the result of  @A + @B but since @B is @X  you
> have @B unified to a variable or symbol

This is right.

> and thus @B is not instantiated, it
> has no value and so you cannot do the + operation,

On the Pilog level, @B is indeed unified with @X. But in the Lisp call @B
has the value NIL.


> in my understanding you
> should have got an exception or an error

It is an important feature of PicoLisp that arithmetic functions treat NIL as
"not a number" and not as an error:

   : (+ 3 'a 4)
   !? (+ 3 'a 4)
   a -- Number expected
   ?

   : (+ 3 NIL 4)
   -> NIL


> I suppose what happens is first rule don't give an error trying to add @A
> and @B, it simply fails and returns with @C not unified (not binded) and
> thus the cut is never executed so it tries next rule, the second one, now
> it succeeds and executes the cut stopping further matching.

Exactly.

☺/ A!ex

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


Re: some questions relating pilog

2022-02-15 Thread pd
On Sat, Feb 12, 2022 at 8:37 AM Alexander Burger 
wrote:

>
> > >(be + (@A @B @C)
> > >   (^ @C (+ @A @B))
> > >   T )
> > >
> > >(be + (@A @B @C)
> > >   (^ @B (- @C @A))
> > >   T )
> > I suppose pilog search for rules in order, so the goal  (? (+ 3 @X 7))
> > always matches first three rules with the cut,
>
> It tries the first one but does not succeed. The second one matches, so the
> others are not tried because of the cut.
>

This is interesting, in my understanding when matching the first rule it
should try to unify @C to the result of  @A + @B but since @B is @X  you
have @B unified to a variable or symbol and thus @B is not instantiated, it
has no value and so you cannot do the + operation, in my understanding you
should have got an exception or an error, in fact this is what you get in
prolog:

 ?- +(3,X,7).
   Call: (8) +(3, _7186, 7) ? creep
   Call: (9) 3 is 7-_7186 ? creep
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR:[9] 3 is 7-_7806
ERROR:[8] +(3,_7832,7) at /prolog_.pl:30
ERROR:[7] 


I suppose what happens is first rule don't give an error trying to add @A
and @B, it simply fails and returns with @C not unified (not binded) and
thus the cut is never executed so it tries next rule, the second one, now
it succeeds and executes the cut stopping further matching.

In this case my question is, what value is binded to @B when passed to lisp
function + ?   is it nil maybe?   or function ^ detects an unbinded pilog
variable and just returns with false?


> but shouldn't the last goal
> > match also one of the first three line thus avoiding backtracking?
>
> A query like (+ @X @Y 7) will not be satisfied by the first four rules, so

finally the fifth fires (and finally terminates recursion with the fourth).
>

so this is the same case as before, this works because (^ @X (op @A @B))
fails when @A or @B are not binded, being possible to explorer other rule
matching

regards


Re: some questions relating pilog

2022-02-11 Thread Alexander Burger
Hi pd,

> > The environments are nested association lists, with numbers for the levels
> > and
> > then the symbols for the values at these levels.
>
> and levels are related to backtracking somehow?

Yes. When looking up values for symbols, the symbols at individual levels are
unified with constants or other symbols at these levels.


> >(be + (@A @B @C)
> >   (^ @C (+ @A @B))
> >   T )
> >
> >(be + (@A @B @C)
> >   (^ @B (- @C @A))
> >   T )
> >
> >(be + (@A @B @C)
> >   (^ @A (- @C @B))
> >   T )
> >
> >(be + (@A 0 @A))
> >
> >(be + (@A @B @C)
> >   (^ @Z (dec @C))
> >   (+ @A @Y @Z)
> >   (^ @B (inc @Y)) )
> > ...
> I suppose pilog search for rules in order, so the goal  (? (+ 3 @X 7))
> always matches first three rules with the cut,

It tries the first one but does not succeed. The second one matches, so the
others are not tried because of the cut.


> but shouldn't the last goal
> match also one of the first three line thus avoiding backtracking?

A query like (+ @X @Y 7) will not be satisfied by the first four rules, so
finally the fifth fires (and finally terminates recursion with the fourth).


> Also, when a goal return a non terminating list, what happend if we try the
> function solve with it? is there any way to get an exception or a stream?

'solve' is not very useful here. You could terminate with a 'throw', but then
you don't have the result. 'pilog' is more general:

   : (make
  (let N 5
 (catch NIL
(pilog '((+ @X @Y 7))
   (and (lt0 (dec 'N)) (throw))
   (link (cons @X @Y)) ) ) ) )
   -> ((7 . 0) (6 . 1) (5 . 2) (4 . 3) (3 . 4))

but still clumsy.

Except for very simple cases I also don't use 'pilog' (e.g. in a database query
'collect' is better), but code it directly:

   : (for ((I . Q) (goal '((+ @X @Y 7))) (prove Q))
  (bind @ (println (cons @X @Y)))
  (T (= I 5)) )
   (7 . 0)
   (6 . 1)
   (5 . 2)
   (4 . 3)
   (3 . 4)
   -> NIL

   : (make
  (for ((I . Q) (goal '((+ @X @Y 7))) (prove Q))
 (bind @ (link (cons @X @Y)))
 (T (= I 5)) ) )
   -> ((7 . 0) (6 . 1) (5 . 2) (4 . 3) (3 . 4))

☺/ A!ex

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


Re: some questions relating pilog

2022-02-11 Thread pd
On Thu, Feb 10, 2022 at 6:27 PM Alexander Burger 
wrote:

>
> Could not resist. I elaborated a little :)
>
> If we define '+' as
>
>(be + (@A @B @C)
>   (^ @C (+ @A @B))  T )
>
>(be + (@A @B @C)
>   (^ @B (- @C @A))  T )
>
>(be + (@A @B @C)
>   (^ @A (- @C @B))  T )
>
>(be + (@A 0 @A))
>
>(be + (@A @B @C)
>   (^ @Z (dec @C))
>   (+ @A @Y @Z)
>   (^ @B (inc @Y)) )
>
> then we can use it as
>
>: (? (+ 3 4 @X))
> @X=7
>
>: (? (+ 3 @X 7))
> @X=4
>
>: (? (+ @X 4 7))
> @X=3
>
>: (? (+ @X @Y 7))
> @X=7 @Y=0
> @X=6 @Y=1
> ...
>
>
I suppose pilog search for rules in order, so the goal  (? (+ 3 @X 7))
always matches first three rules with the cut, but shouldn't the last goal
match also one of the first three line thus avoiding backtracking?   I
think I don't fully understand how it works.

Also, when a goal return a non terminating list, what happend if we try the
function solve with it? is there any way to get an exception or a stream?

regards


Re: some questions relating pilog

2022-02-11 Thread pd
Hi Alex,

On Wed, Feb 9, 2022 at 9:53 PM Alexander Burger  wrote:

>
> > > > : (? (factorial @X 120))
> > > > -> NIL
> > >
>
> > How should be declared factorial primitive to be compatible with reverse
> > lookup?
>
> I have not tried. How is it in real Prolog?
>

In modern prolog you use this form:

fac(0,1).
fac(N,X) :- N #> 0, A #= N - 1, X #= N * X1, fac(A,X1).

but it depends on CLP(FD) which is not implemented in pilog I'm afraid.

A workaround is using an accumulator for both then number and the
factorial, assuming factorial is defined for numbers > 0:

factorial(0,1).
factorial(X, XFact) :- f(X, 1, 1, XFact).
f(N, N, F, F) :- !.
f(N, N0, F0, F) :- succ(N0, N1), F1 is F0 * N1, f(N, N1, F1, F).

But it seems pilog doesn't manage properly this either:

(be fa (0 1))
(be fa (@X @XF) (f @X 1 1 @XF))
(be f (@N @N @F @F) T)
(be f (@N @N0 @F0 @F) (^ @N1 (inc (-> @N0))) (^ @F1 (* (-> @F0) (-> @N1)))
(f @N @N1 @F1 @F))

Now asking for factorial of 6 I get:

: (? (fa 6 @X))
@X=720
-> NIL

the other way works perfectly:

: (? (fa @X 6))
@X=3
-> NIL

: (? (fa @X 1))
@X=0
@X=1
-> NIL

but it haves problems when asking for factorial of 0:

: (? (fa 0 @X))
@X=1


2454 No memory
$

Similar behaviour when asking for factorial of 1,  this time pilogs appears
to hang out without doing nothing but if you press ctrl-C you get a clue
about where it stopped:

: (? (fa 1 @X))
@X=1


(inc (-> @N0))
! (inc (-> @N0))
! (inc (-> @N0))
!  (-> @N1)
! (inc (-> @N0))
! (inc (-> @N0))
! (inc (-> @N0))
.. (several ctrl-C hits)
$

Maybe introducing a predicate asserting N should be greater than 0 but I
didn't find the way.

A similar problem appears when defining list_length predicate, in prolog
you get:

ll([],0).
ll([H|T],N) :- ll(T,N1), N is N1 + 1.

?- ll(X,5).
X = [_606, _612, _618, _624, _630] .

?- ll(X,Y).
X = [],
Y = 0 ;
X = [_860],
Y = 1 ;
X = [_860, _866],
Y = 2 ;
X = [_860, _866, _872],
Y = 3 ;
X = [_860, _866, _872, _878],
Y = 4 ;
X = [_860, _866, _872, _878, _884],
Y = 5 ;
X = [_860, _866, _872, _878, _884, _890],
Y = 6 .

when trying to translate it to pilog I get:

(be ll (NIL 0))
(be ll ((@ . @T) @N) (ll @T @N0) (^ @N (inc (-> @N0

(? (ll NIL @X))
@X=0
-> NIL

(? (ll (1) @X))
@X=1
-> NIL

(? (ll (b a) @X))  #->  this is b(a) ? this is the syntax used
in "be" then it should be X=1
@X=2
-> NIL

(? (ll (b (a)) @X))#->  same here, semantics is not clear for me
@X=2
-> NIL

(? (ll @L 2))  # this apparently hangs
@L=(@ @)


(? (ll @L @M))
@L=NIL @M=0
@L=(@) @M=1
@L=(@ @) @M=2
@L=(@ @ @) @M=3
@L=(@ @ @ @) @M=4
..

which is ok


> To take an example a bit simpler than the factorial function, you could
> start
> with addition as:
>
>
That's a nice implementation of logic + specially your next post which
solves +(X,Y,4) for example. Still there's something I don't fully
understand, I will comment it in your next post.


> But where will that end? Should we also handle two or three variables,
> generating all combinations of natural numbers? This could surely be done
> (similar to what 'append/3' does for lists), but I never saw a need for
> that.
>
> Not really a pragmatical use or need, but it could be useful in some
situations. I really was testing how similar is pilog to real prolog.


> The second one. But I think it does not matter, you can pass any pattern
> to a
> predicate, it is matched in any case.
>
> but the way it matches it's important because you have to match compound
terms not treating them as lists


> > what is supposed to mean (be p (r (b))) if anything?
>
> Yeah, there is no "meaning". It is just a pattern.
>
>: (? (p @A @B))
> @A=r @B=(b)
>
>
but that matching corresponds to a prolog list or a prolog term?  I mean,
that matches with prolog [r b] or with prolog r(b) ?


>
> > May you explain the estructure of a pilog environment (and the use of
> unify
> > function)
>
> The environments are nested association lists, with numbers for the levels
> and
> then the symbols for the values at these levels.
>
> and levels are related to backtracking somehow?


regards


Re: some questions relating pilog

2022-02-10 Thread Alexander Burger
On Wed, Feb 09, 2022 at 09:46:01PM +0100, Alexander Burger wrote:
> To take an example a bit simpler than the factorial function, you could start
> with addition as:
> 
>(be + (@A @B @C)
>   (^ @A (- @C @B)) )
> ...

Could not resist. I elaborated a little :)

If we define '+' as

   # (+ 3 4 7)
   # (+ 3 4 @X)
   (be + (@A @B @C)
  (^ @C (+ @A @B))
  T )

   # (+ 3 @X 7)
   (be + (@A @B @C)
  (^ @B (- @C @A))
  T )

   # (+ @X 4 7)
   (be + (@A @B @C)
  (^ @A (- @C @B))
  T )

   # (+ @X @Y 7)
   (be + (@A 0 @A))

   (be + (@A @B @C)
  (^ @Z (dec @C))
  (+ @A @Y @Z)
  (^ @B (inc @Y)) )

then we can use it as

   : (? (+ 3 4 7))
   -> T

   : (? (+ 3 4 @X))
@X=7

   : (? (+ 3 @X 7))
@X=4

   : (? (+ @X 4 7))
@X=3

   : (? (+ @X @Y 7))
@X=7 @Y=0
@X=6 @Y=1
@X=5 @Y=2
@X=4 @Y=3
@X=3 @Y=4
@X=2 @Y=5
@X=1 @Y=6
@X=0 @Y=7
@X=-1 @Y=8
@X=-2 @Y=9
@X=-3 @Y=10
@X=-4 @Y=11
@X=-5 @Y=12
...

☺/ A!ex

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


Re: some questions relating pilog

2022-02-09 Thread Alexander Burger
Hi pd,

> > > : (? (factorial @X 120))
> > > -> NIL
> >
> > This is another issue. This Pilog version of factorial cannot do reverse
> > lookup,
> > as it calculate numeric values via Lisp calls.
> ...
> Ok, I suspected that but is there any way to do arithmetic in pilog?  My
> understanding is you have to use picolisp for arithmetic
> 
> How should be declared factorial primitive to be compatible with reverse
> lookup?

I have not tried. How is it in real Prolog?

To take an example a bit simpler than the factorial function, you could start
with addition as:

   (be + (@A @B @C)
  (^ @A (- @C @B)) )

   (be + (@A @B @C)
  (^ @B (- @C @A)) )

   (be + (@A @B @C)
  (^ @C (+ @A @B)) )

With that, you can do thing like:

   : (? (+ 3 4 7))
   -> T

   : (? (+ 3 4 @X))
@X=7

   : (? (+ 3 @X 7))
@X=4

   : (? (+ @X 4 7))
@X=3

But where will that end? Should we also handle two or three variables,
generating all combinations of natural numbers? This could surely be done
(similar to what 'append/3' does for lists), but I never saw a need for that.


> May you tell me what syntax is the right one for prolog primitives
> translated to pilog?
> 
> prolog  pilog
> p(r(b)).(be p (r (b)))  -(1)-   or
> (be p ((r (b-(2)-   or

I would say the first one.


> (be p ((r b)))  -(3)-
> p(z(a),b)   (be p ((z a) b))-(1)-   or
> (be p ((z (a)) b))  -(2)-

The second one. But I think it does not matter, you can pass any pattern to a
predicate, it is matched in any case.


> what is supposed to mean (be p (r (b))) if anything?

Yeah, there is no "meaning". It is just a pattern.

   : (? (p r @X))
@X=(b)

   $: (? (p q @X))
   -> NIL

   : (? (p @A @B))
@A=r @B=(b)

   : (? (p @A (@B)))
@A=r @B=b


> May you explain the estructure of a pilog environment (and the use of unify
> function)

The environments are nested association lists, with numbers for the levels and
then the symbols for the values at these levels.


> and how pilog clauses are converted to property lists?   what
> kind of unification algorithm uses pilog?   maybe in a PilCon session

They are not converted at all. They are stored directly as a list under the 'T'
property of the predicate's symbol. Unification looks them up for each level.

☺/ A!ex

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


Re: some questions relating pilog

2022-02-09 Thread pd
Hi Alex, thanks for quick reply

On Wed, Feb 9, 2022 at 8:13 AM Alexander Burger  wrote:

>
> > Is the reference documentation incorrect?
>
> No, but it seems that you looked at the reference for pil21.
>
> The syntax for calling Lisp expressions in Pilog was made a little
> friendlier in
> pil21, by binding variables directly, so that calling '->' is normally not
> needed any more.
>
>
Ok, thanks for the clarification


> > but I cannot get an answer for the inverse query:
> >
> > : (? (factorial @X 120))
> > -> NIL
>
> This is another issue. This Pilog version of factorial cannot do reverse
> lookup,
> as it calculate numeric values via Lisp calls.
>

Ok, I suspected that but is there any way to do arithmetic in pilog?  My
understanding is you have to use picolisp for arithmetic

How should be declared factorial primitive to be compatible with reverse
lookup?


> > Also I would like to know if pilog unification deals with compound
> > predicates, I mean, in prolog you can write:
> >
> > p(a).
> > p(R(y)).
> > ? p( X )
> > X=a
> > X=R(y)
> >
> > Querying for values of X veryfing a p predicate. How can you get that in
> > pilog?
>
> Yes, you can do that, but not in that direct syntax.
>
> You could take a look at how 'not', 'call' or 'or' are implemented in
> @lib/pilog.l for examples.
>
>
Ok, I'm doing, I'll post any question about it

May you tell me what syntax is the right one for prolog primitives
translated to pilog?

prolog  pilog
p(r(b)).(be p (r (b)))  -(1)-   or
(be p ((r (b-(2)-   or
(be p ((r b)))  -(3)-
p(z(a),b)   (be p ((z a) b))-(1)-   or
(be p ((z (a)) b))  -(2)-

what is supposed to mean (be p (r (b))) if anything?
May you explain the estructure of a pilog environment (and the use of unify
function)  and how pilog clauses are converted to property lists?   what
kind of unification algorithm uses pilog?   maybe in a PilCon session

thanks and best regards


Re: some questions relating pilog

2022-02-08 Thread Alexander Burger
Hi pd,

> I'm using picolisp version 18.12.27 C in a debian 10.10 based distro,
> ...
> I'm playing with pilog and there're some examples that does not run:
> ...
>(^ @I (inc @C)) )
> ...
> I can make it work if I use the -> functon this way:
> ...
>(^ @I (inc (-> @C))) )
> 
> Is the reference documentation incorrect?

No, but it seems that you looked at the reference for pil21.

The syntax for calling Lisp expressions in Pilog was made a little friendlier in
pil21, by binding variables directly, so that calling '->' is normally not
needed any more.


> 2- the example of factorial in Mia's blog  [2] :
> ...
> Again I get it working using the -> function this way:

Yes, exactly. So for pil64 and pil32 the old syntax is still required.

> I assume the use of -> function is needed but that means picolisp
> documentation and Mia's blog is wrong.

Not wrong, but it focuses exclusively on pil21.

> ...
> but I cannot get an answer for the inverse query:
> 
> : (? (factorial @X 120))
> -> NIL

This is another issue. This Pilog version of factorial cannot do reverse lookup,
as it calculate numeric values via Lisp calls.


> Also I would like to know if pilog unification deals with compound
> predicates, I mean, in prolog you can write:
> 
> p(a).
> p(R(y)).
> ? p( X )
> X=a
> X=R(y)
> 
> Querying for values of X veryfing a p predicate. How can you get that in
> pilog?

Yes, you can do that, but not in that direct syntax.

You could take a look at how 'not', 'call' or 'or' are implemented in
@lib/pilog.l for examples.

☺/ A!ex

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


some questions relating pilog

2022-02-08 Thread pd
Hello,

I'm using picolisp version 18.12.27 C in a debian 10.10 based distro,
installed as package picolisp 18.12-1

I'm playing with pilog and there're some examples that does not run:

1- the example in doc reference for repeat/0 [1] :

: (be integer (@I)   # Generate unlimited supply of integers
   (^ @C (box 0))# Init to zero
   (repeat)  # Repeat from here
   (^ @I (inc @C)) )
-> integer

: (? (integer @X))
 @X=1
 @X=2
 @X=3
 @X=4.   # Stop
-> NIL

but I got nothing printed, no values for @X var, it keeps doing apparently
nothing until I kill the process

I can make it work if I use the -> functon this way:

: (be integer (@I)
   (^ @C (box 0))
   (repeat)
   (^ @I (inc (-> @C))) )

Is the reference documentation incorrect?

2- the example of factorial in Mia's blog  [2] :

: (be factorial (0 1) T)
-> factorial

: (be factorial (@N @X)
  (^ @A (dec @N))
  (factorial @A @B)
  (^ @X (* @N @B)) )
-> factorial

: (? (factorial 5 @X))
 @X=120
-> NIL

but when I execute (? (factorial 5 @X)) in my lisp I got:

: (? (factorial 5 @X))
-> NIL

only valid result is when executing  (? (factorial 0 @X)) :

: (? (factorial 0 @X))
 @X=1
-> NIL

debugging does not help:

: (? factorial (factorial 0 @X))
1 (factorial 0 1)
 @X=1
-> NIL

: (? factorial (factorial 5 @X))
2 (factorial 5 @X)
-> NIL

Again I get it working using the -> function this way:

: (be factorial (@N @X)
  (^ @A (dec (-> @N)))
  (factorial @A @B)
  (^ @X (* (-> @N) (-> @B))) )
-> factorial

Now:

: (? (factorial 5 @X))
 @X=120
-> NIL

but I cannot get an answer for the inverse query:

: (? (factorial @X 120))
-> NIL

any hint?

I assume the use of -> function is needed but that means picolisp
documentation and Mia's blog is wrong.

Also I would like to know if pilog unification deals with compound
predicates, I mean, in prolog you can write:

p(a).
p(R(y)).
? p( X )
X=a
X=R(y)

Querying for values of X veryfing a p predicate. How can you get that in
pilog?

I've tried this two:

(be p ((R y)))

(be pp ((R (y

and it appears to work:

(? (p @X))
@X=(R y)
-> NIL

(? (pp @X))
@X=(R (y))
-> NIL

but I'm not sure it's the same semantics as prolog, because this appears to
me as stating p as a list , not a compound predicate.

In other words, what is the correct translation to this prolog clauses to
pilog?

prolog  pilog
p(a).   (be p (a))
p(x,y). (be p (x y))
p(r(b)).(be p (r (b)))  ? not working  (-> NIL)
(be p ((r (b? gets @X=(r (b))
(be p ((r b)))  ? gets @X=(r b)
p(z(a),b)   (be p ((z a) b))? gets @X=(z a) @Y=b
(be p ((z (a)) b))  ? gets @X=(z (a)) @Y=b


best regards

[1] R (software-lab.de) 
[2] How to use Pilog in PicoLisp (picolisp-explored.com)



Re: Pil21 feature questions

2020-12-22 Thread Danilo Kordic
> (map * Lst (circ Factor))

*`[let [Circ [1 .]]*
*   '[let [`Circ Factor]*
* (mapcar * Lst `Circ)) ] ]*

On Tue, Nov 10, 2020, 13:57 Andras Pahi  wrote:

> Hi Alex,
>
> Thank you for the descriptions.
>
> Regards,
> Andras
>
> > On 2020. Nov 10., at 12:49, Alexander Burger 
> wrote:
> >
> > Hi Andras,
> >
> >> I would like to ask some questions on Pil21 features.
> >> It is enough if you points to some examples where I could dig into the
> >> details...
> >
> > These are indeed very good questions! Thanks that you ask, they need to
> be
> > clarified.
> >
> >
> >> - What is special in the ‘priv’ namespace handling?
> >>  pil64 used it to store (private) symbols.
> >
> > I noticed that the way pil64 implemented the 'private' function was not
> good.
> >
> > It created a normal namespace 'priv' on-the-fly, interned the given
> symbols into
> > that namespace, and then put 'priv' as the *second* namespace in the
> search
> > order:
> >
> >   : (private) foo  # Intern 'foo' in 'priv'
> >
> >   : (symbols)  # Search order
> >   -> (pico priv)
> >
> > So now 'foo' is indeed private. The problem is that *if' another symbol
> named
> > "foo" exists in 'pico', it overshadoes the 'foo' in 'priv', and this is
> not what
> > is expected for a private symbol.
> >
> >
> > Pil21 implements a special handling for 'priv'. Now 'priv' is part of the
> > interpreter core, and behaves a little different from normal namespaces


Re: Pil21 feature questions

2020-11-10 Thread Andras Pahi
Hi Alex,

Thank you for the descriptions.

Regards,
Andras

> On 2020. Nov 10., at 12:49, Alexander Burger  wrote:
> 
> Hi Andras,
> 
>> I would like to ask some questions on Pil21 features.
>> It is enough if you points to some examples where I could dig into the
>> details...
> 
> These are indeed very good questions! Thanks that you ask, they need to be
> clarified.
> 
> 
>> - What is special in the ‘priv’ namespace handling?
>>  pil64 used it to store (private) symbols.
> 
> I noticed that the way pil64 implemented the 'private' function was not good.
> 
> It created a normal namespace 'priv' on-the-fly, interned the given symbols 
> into
> that namespace, and then put 'priv' as the *second* namespace in the search
> order:
> 
>   : (private) foo  # Intern 'foo' in 'priv'
> 
>   : (symbols)  # Search order
>   -> (pico priv)
> 
> So now 'foo' is indeed private. The problem is that *if' another symbol named
> "foo" exists in 'pico', it overshadoes the 'foo' in 'priv', and this is not 
> what
> is expected for a private symbol.
> 
> 
> Pil21 implements a special handling for 'priv'. Now 'priv' is part of the
> interpreter core, and behaves a little different from normal namespaces.
> 
>   : (private) foo  # Intern 'foo' in 'priv'
> 
>   : (symbols)  # Search order
>   -> (pico)
> 
>   : (all 'priv)
>   -> (priv~foo)
> 
> 'priv' is not put into the search order at all, but internally it is always
> searched first. That way it will not be overridden by symbols with the same
> names in 'pico', but still *new* symbols will be interned in 'pico'.
> 
> 
>> - What is the purpose of the ‘~’ marker in the namespaces?
> 
> This is only used for error checking: To check in 'symbols' that the arguments
> are really namespaces, and that 'nsp' in 'nsp~foo' is OK.
> 
> 
>> - What does it mean, that map functions accept atomic arguments?
>>  It is not required to pass lists as arguments?
>>  Atomic arguments are handled as 1-item lists or infinite lists with the 
>> same item?
> 
> Yes, the latter.
> 
> In pil32 and pil64 you could call
> 
>   : (mapcar * (1 2 3 4 5 6) (2 .))
>   -> (2 4 6 8 10 12)
> 
> i.e. supply an infinite list of 2's.
> 
> Now in pil21 you can simply call
> 
>   : (mapcar * (1 2 3 4 5 6) 2)
> 
> This is especially useful if '2' is not a constant, e.g.
> 
>   (mapcar * Lst Factor)
> 
> In pil64 you would need to build the circular list explicitly:
> 
>   (mapcar * Lst (circ Factor))
> 
> ☺/ A!ex
> 
> -- 
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


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


Re: Pil21 feature questions

2020-11-10 Thread Alexander Burger
Hi Andras,

> I would like to ask some questions on Pil21 features.
> It is enough if you points to some examples where I could dig into the
> details...

These are indeed very good questions! Thanks that you ask, they need to be
clarified.


> - What is special in the ‘priv’ namespace handling?
>   pil64 used it to store (private) symbols.

I noticed that the way pil64 implemented the 'private' function was not good.

It created a normal namespace 'priv' on-the-fly, interned the given symbols into
that namespace, and then put 'priv' as the *second* namespace in the search
order:

   : (private) foo  # Intern 'foo' in 'priv'

   : (symbols)  # Search order
   -> (pico priv)

So now 'foo' is indeed private. The problem is that *if' another symbol named
"foo" exists in 'pico', it overshadoes the 'foo' in 'priv', and this is not what
is expected for a private symbol.


Pil21 implements a special handling for 'priv'. Now 'priv' is part of the
interpreter core, and behaves a little different from normal namespaces.

   : (private) foo  # Intern 'foo' in 'priv'

   : (symbols)  # Search order
   -> (pico)

   : (all 'priv)
   -> (priv~foo)

'priv' is not put into the search order at all, but internally it is always
searched first. That way it will not be overridden by symbols with the same
names in 'pico', but still *new* symbols will be interned in 'pico'.


> - What is the purpose of the ‘~’ marker in the namespaces?

This is only used for error checking: To check in 'symbols' that the arguments
are really namespaces, and that 'nsp' in 'nsp~foo' is OK.


> - What does it mean, that map functions accept atomic arguments?
>   It is not required to pass lists as arguments?
>   Atomic arguments are handled as 1-item lists or infinite lists with the 
> same item?

Yes, the latter.

In pil32 and pil64 you could call

   : (mapcar * (1 2 3 4 5 6) (2 .))
   -> (2 4 6 8 10 12)

i.e. supply an infinite list of 2's.

Now in pil21 you can simply call

   : (mapcar * (1 2 3 4 5 6) 2)

This is especially useful if '2' is not a constant, e.g.

   (mapcar * Lst Factor)

In pil64 you would need to build the circular list explicitly:

   (mapcar * Lst (circ Factor))

☺/ A!ex

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


Pil21 feature questions

2020-11-10 Thread Andras Pahi
Hi Alex,

I would like to ask some questions on Pil21 features.
It is enough if you points to some examples where I could dig into the 
details...

- What is special in the ‘priv’ namespace handling?
  pil64 used it to store (private) symbols.

- What is the purpose of the ‘~’ marker in the namespaces?

- What does it mean, that map functions accept atomic arguments?
  It is not required to pass lists as arguments?
  Atomic arguments are handled as 1-item lists or infinite lists with the same 
item?

Thank you,
Andras


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


Re: MiniPicolisp Questions

2020-04-22 Thread C K Kashyap
oops .. hit send too early -
Got it. The idea was not to encode more types - just reduce the
"complexity" of tagged pointers and remove the word aligned function
address restriction. Yes, a separate byte heap would totally be much more
complex. One of the reasons of this desire was to build miniPicoLis with
TCC :) which does not seem to generate WORD aligned function addresses. The
second reason for this desire was to have a system for "instructive"
purposes - where it seems that doubling the space may not be such a bad
idea. The wasted space would be clearly visible and perhaps help with the
appreciation for the tagged pointer as an optimization.

But yes, I can clearly see that a 9byte cell is not a good idea :)

On Wed, Apr 22, 2020 at 8:27 AM C K Kashyap  wrote:

> Got it. The idea was not to encode more types - just reduce the
> "complexity" of tagged pointers and impose the word aligned function
> address restriction but from what I gather. Yes, a separate byte heap would
> totally be much ore complex. One of the reasons of this desire was to build
> miniPicoLis with TCC :) which does not seem to generate WORD
> aligned function addresses. The second reason for this desire was to have a
> system for "instructive" purpose - where it seems that doubling the space
> may not be such a bad idea. The wasted space would be clearly visible and
> perhaps help with the appreciation for the tagged pointer as an
> optimization.
>
> But yes, I can clearly see that a 9byte cell is not a good idea :)
>
> Regards,
> Kashyap
>
> On Wed, Apr 22, 2020 at 7:28 AM Alexander Burger 
> wrote:
>
>> Hi Kashyap,
>>
>> > Quick question - when you mentioned "doubling of space" - perhaps you
>> were
>> > talking about systems that can only have WORD aligned pointers - is that
>> > correct?
>>
>> Not only. Also on a byte-addressed machine, imagine if you make a cell of
>> two
>> 9-byte words, you get every cell aligned at another offet, with terrible
>> performance. On most machines you will get a bus error anyway.
>>
>> So my second proposal was to use a separate heap of bytes. But this also
>> gets
>> extremely uncomfortable and inefficient, as you need to index into two
>> heaps for
>> each access. You won't get a simpler system, as you intended.
>>
>> And what to do with that byte? Encode more types than fit into the 4 bits
>> in
>> Pil? Then you must also interprete those types at runtime during
>> interpretation.
>> Seems you open a pandora box ;)
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: MiniPicolisp Questions

2020-04-22 Thread C K Kashyap
Got it. The idea was not to encode more types - just reduce the
"complexity" of tagged pointers and impose the word aligned function
address restriction but from what I gather. Yes, a separate byte heap would
totally be much ore complex. One of the reasons of this desire was to build
miniPicoLis with TCC :) which does not seem to generate WORD
aligned function addresses. The second reason for this desire was to have a
system for "instructive" purpose - where it seems that doubling the space
may not be such a bad idea. The wasted space would be clearly visible and
perhaps help with the appreciation for the tagged pointer as an
optimization.

But yes, I can clearly see that a 9byte cell is not a good idea :)

Regards,
Kashyap

On Wed, Apr 22, 2020 at 7:28 AM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > Quick question - when you mentioned "doubling of space" - perhaps you
> were
> > talking about systems that can only have WORD aligned pointers - is that
> > correct?
>
> Not only. Also on a byte-addressed machine, imagine if you make a cell of
> two
> 9-byte words, you get every cell aligned at another offet, with terrible
> performance. On most machines you will get a bus error anyway.
>
> So my second proposal was to use a separate heap of bytes. But this also
> gets
> extremely uncomfortable and inefficient, as you need to index into two
> heaps for
> each access. You won't get a simpler system, as you intended.
>
> And what to do with that byte? Encode more types than fit into the 4 bits
> in
> Pil? Then you must also interprete those types at runtime during
> interpretation.
> Seems you open a pandora box ;)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: MiniPicolisp Questions

2020-04-22 Thread Guido Stepken
Nope. Polymorphic Inline Caching. And why shouldn't JIT compilers use MMU
"memory address violation exception" to check for end of range? Same for
TLB.

I could flood you with hundreds of papers about that. I am using that all
time.

Of you were right and such knowledgeable, PicoLisp would run fast. But it
doesn't. So take my pointers and - learn something new! ;-)

Best regards, Guido

Am Mittwoch, 22. April 2020 schrieb Alexander Burger :
> On Wed, Apr 22, 2020 at 03:49:41PM +0200, Guido Stepken wrote:
>> Well, we have year 2020, not Dijksra 1978. Even embedded systems have a
MMU
>> and you get "Memory Access Violation", so no pointer rage checks needed
to
>> be handled by CPU any longer.
>
> Sigh, you don't understand at all how a Lisp interpreter works.
> It is *all* type checks. We have dynamic data. Please stop
> talking about things you have no clue of!
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: MiniPicolisp Questions

2020-04-22 Thread Alexander Burger
Hi Kashyap,

> Quick question - when you mentioned "doubling of space" - perhaps you were
> talking about systems that can only have WORD aligned pointers - is that
> correct?

Not only. Also on a byte-addressed machine, imagine if you make a cell of two
9-byte words, you get every cell aligned at another offet, with terrible
performance. On most machines you will get a bus error anyway.

So my second proposal was to use a separate heap of bytes. But this also gets
extremely uncomfortable and inefficient, as you need to index into two heaps for
each access. You won't get a simpler system, as you intended.

And what to do with that byte? Encode more types than fit into the 4 bits in
Pil? Then you must also interprete those types at runtime during interpretation.
Seems you open a pandora box ;)

☺/ A!ex

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



Re: MiniPicolisp Questions

2020-04-22 Thread C K Kashyap
Hi Alex,
Quick question - when you mentioned "doubling of space" - perhaps you were
talking about systems that can only have WORD aligned pointers - is that
correct?
Regards,
Kashyap


On Wed, Apr 22, 2020 at 6:56 AM Guido Stepken  wrote:

> Well, we have year 2020, not Dijksra 1978. Even embedded systems have a
> MMU and you get "Memory Access Violation", so no pointer rage checks needed
> to be handled by CPU any longer. Those formerly needed range checks, eating
> up clock cycles, now are deeply sticking in MMU and IOMMU ... Bang! -
> Exception!
>
> Also reading about modern "multi generational garbage collectors" will
> explain, why garbage collected (functional, pure OO) languages have kept up
> with C/C++ statically machine code. Julia language, sitting on FemtoLisp
> JIT engine, in some times even ist faster than C
>
> Have fun!
>
> Am Mittwoch, 22. April 2020 schrieb Alexander Burger  >:
> > Hi Geo,
> >
> >> I think you mean 0xF000 for everything? This is indeed cool! but hmm
> does
> >> it limit the memory for each data type?
> >
> > Yes, what Guido writes is nonsense. Fixed-sized address spaces are a
> terrible
> > solution. Doesn't scale, and is extremely inefficient due to the
> necessary
> > pointer range checks.
> >
> > PicoLisp's way is far superior, because the tag bits come "free", they
> are
> > implicit by the natural pointer alignments.
> >
> > ☺/ A!ex
> >
> > --
> > UNSUBSCRIBE: mailto:picolisp@software-labde 
> ?subject=Unsubscribe
> >
> >


Re: MiniPicolisp Questions

2020-04-22 Thread Alexander Burger
On Wed, Apr 22, 2020 at 03:49:41PM +0200, Guido Stepken wrote:
> Well, we have year 2020, not Dijksra 1978. Even embedded systems have a MMU
> and you get "Memory Access Violation", so no pointer rage checks needed to
> be handled by CPU any longer.

Sigh, you don't understand at all how a Lisp interpreter works.
It is *all* type checks. We have dynamic data. Please stop
talking about things you have no clue of!

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


Re: MiniPicolisp Questions

2020-04-22 Thread Guido Stepken
Well, we have year 2020, not Dijksra 1978. Even embedded systems have a MMU
and you get "Memory Access Violation", so no pointer rage checks needed to
be handled by CPU any longer. Those formerly needed range checks, eating up
clock cycles, now are deeply sticking in MMU and IOMMU ... Bang! -
Exception!

Also reading about modern "multi generational garbage collectors" will
explain, why garbage collected (functional, pure OO) languages have kept up
with C/C++ statically machine code. Julia language, sitting on FemtoLisp
JIT engine, in some times even ist faster than C.

Have fun!

Am Mittwoch, 22. April 2020 schrieb Alexander Burger :
> Hi Geo,
>
>> I think you mean 0xF000 for everything? This is indeed cool! but hmm does
>> it limit the memory for each data type?
>
> Yes, what Guido writes is nonsense. Fixed-sized address spaces are a
terrible
> solution. Doesn't scale, and is extremely inefficient due to the necessary
> pointer range checks.
>
> PicoLisp's way is far superior, because the tag bits come "free", they are
> implicit by the natural pointer alignments.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
>


Re: MiniPicolisp Questions

2020-04-22 Thread George-Phillip Orais
Hi Alex,

> Yes, what Guido writes is nonsense. Fixed-sized address spaces are a
terrible
> solution. Doesn't scale, and is extremely inefficient due to the necessary
> pointer range checks.
>
> PicoLisp's way is far superior, because the tag bits come "free", they are
> implicit by the natural pointer alignments.

I see, that make sense, thank you for the explanation.


Hi Guido,

> I meat: "0xE000 for everything, that must be persisted to disk". There,
of course, you can also reserve three slots for float, integer, string ...

If so, will it conflict with strings? Anyway thanks for sharing your
thoughts, its nice to know other approach existed, we look forward to see
your ASIC LispM someday soon..


BR,
Geo


Re: MiniPicolisp Questions

2020-04-22 Thread Guido Stepken
I meat: "0xE000 for everything, that must be persisted to disk". There, of
course, you can also reserve three slots for float, integer, string ...

Best regards, Guido

Am Mittwoch, 22. April 2020 schrieb George-Phillip Orais <
orais.georgephil...@gmail.com>:
> Hi Guido,
> I think you mean 0xF000 for everything? This is indeed cool! but hmm does
it limit the memory for each data type? Like what if the application uses
only integers so does it mean it cannot use the memory location for float
and strings?
>
> BR,
> Geo
> On Wed, Apr 22, 2020 at 8:44 PM Guido Stepken  wrote:
>>
>> Hi Kashyap!
>>
>> Reserving 1-3 bit from 32 or 64 bit register for special purposes, e.g.
indicating type or as persistence flag (ORM-wrapper) is the old fashioned
way. It unnecessarily costs cycles, reduces precision ...
>>
>> The modern, "fully functional" (no state bits anywhere!) - and correct -
way would be to indicate type by its position in memory:
>>
>> 0xC000 all floats, 0xD000 all integers, 0xE000 all strings, 0xD000
everything, that have to be persisted do disk. Let another CPU do the
persistence! ;-)
>>
>> Have fun!
>>
>> Best, Guido Stepken
>>
>> Am Mittwoch, 22. April 2020 schrieb C K Kashyap :
>> > Thanks Alex,
>> > I was thinking of increased memory space - not exactly doubling -  I
was thinking it would just be one additional byte per CELL. Ofcourse this
additional byte would not have the same lifetime of the CELL so it should
not need any extra management.
>> > I feel encouraged - I'll give it a try :)
>> > Regards,
>> > Kashyap
>> > On Tue, Apr 21, 2020 at 10:11 PM Alexander Burger 
wrote:
>> >>
>> >> Hi Kashyap,
>> >>
>> >> > About the the CELL having an additional byte, I meant that the CELL
size
>> >> > would be 2*WORD + 1... that should work too right? I would not need
any
>> >> > masking in that case.
>> >>
>> >> I see. Yes, that would work. But it would either double the memory
usage, or
>> >> require some management of this additional byte (e.g. in a separate,
parallel
>> >> byte heap), which complicates things a lot more than it benefits.
>> >>
>> >> ☺/ A!ex
>> >>
>> >>
>> >> --
>> >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>> >


Re: MiniPicolisp Questions

2020-04-22 Thread Alexander Burger
Hi Geo,

> I think you mean 0xF000 for everything? This is indeed cool! but hmm does
> it limit the memory for each data type?

Yes, what Guido writes is nonsense. Fixed-sized address spaces are a terrible
solution. Doesn't scale, and is extremely inefficient due to the necessary
pointer range checks.

PicoLisp's way is far superior, because the tag bits come "free", they are
implicit by the natural pointer alignments.

☺/ A!ex

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


Re: MiniPicolisp Questions

2020-04-22 Thread George-Phillip Orais
Hi Guido,

I think you mean 0xF000 for everything? This is indeed cool! but hmm does
it limit the memory for each data type? Like what if the application uses
only integers so does it mean it cannot use the memory location for float
and strings?


BR,
Geo

On Wed, Apr 22, 2020 at 8:44 PM Guido Stepken  wrote:

> Hi Kashyap!
>
> Reserving 1-3 bit from 32 or 64 bit register for special purposes, e.g.
> indicating type or as persistence flag (ORM-wrapper) is the old fashioned
> way. It unnecessarily costs cycles, reduces precision ...
>
> The modern, "fully functional" (no state bits anywhere!) - and correct -
> way would be to indicate type by its position in memory:
>
> 0xC000 all floats, 0xD000 all integers, 0xE000 all strings, 0xD000
> everything, that have to be persisted do disk. Let another CPU do the
> persistence! ;-)
>
> Have fun!
>
> Best, Guido Stepken
>
> Am Mittwoch, 22. April 2020 schrieb C K Kashyap :
> > Thanks Alex,
> > I was thinking of increased memory space - not exactly doubling -  I was
> thinking it would just be one additional byte per CELL. Ofcourse this
> additional byte would not have the same lifetime of the CELL so it should
> not need any extra management.
> > I feel encouraged - I'll give it a try :)
> > Regards,
> > Kashyap
> > On Tue, Apr 21, 2020 at 10:11 PM Alexander Burger 
> wrote:
> >>
> >> Hi Kashyap,
> >>
> >> > About the the CELL having an additional byte, I meant that the CELL
> size
> >> > would be 2*WORD + 1... that should work too right? I would not need
> any
> >> > masking in that case.
> >>
> >> I see. Yes, that would work. But it would either double the memory
> usage, or
> >> require some management of this additional byte (e.g. in a separate,
> parallel
> >> byte heap), which complicates things a lot more than it benefits.
> >>
> >> ☺/ A!ex
> >>
> >>
> >> --
> >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
> >


Re: MiniPicolisp Questions

2020-04-22 Thread Guido Stepken
Hi Kashyap!

Reserving 1-3 bit from 32 or 64 bit register for special purposes, e.g.
indicating type or as persistence flag (ORM-wrapper) is the old fashioned
way. It unnecessarily costs cycles, reduces precision ...

The modern, "fully functional" (no state bits anywhere!) - and correct -
way would be to indicate type by its position in memory:

0xC000 all floats, 0xD000 all integers, 0xE000 all strings, 0xD000
everything, that have to be persisted do disk. Let another CPU do the
persistence! ;-)

Have fun!

Best, Guido Stepken

Am Mittwoch, 22. April 2020 schrieb C K Kashyap :
> Thanks Alex,
> I was thinking of increased memory space - not exactly doubling -  I was
thinking it would just be one additional byte per CELL. Ofcourse this
additional byte would not have the same lifetime of the CELL so it should
not need any extra management.
> I feel encouraged - I'll give it a try :)
> Regards,
> Kashyap
> On Tue, Apr 21, 2020 at 10:11 PM Alexander Burger 
wrote:
>>
>> Hi Kashyap,
>>
>> > About the the CELL having an additional byte, I meant that the CELL
size
>> > would be 2*WORD + 1... that should work too right? I would not need any
>> > masking in that case.
>>
>> I see. Yes, that would work. But it would either double the memory
usage, or
>> require some management of this additional byte (e.g. in a separate,
parallel
>> byte heap), which complicates things a lot more than it benefits.
>>
>> ☺/ A!ex
>>
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: MiniPicolisp Questions

2020-04-21 Thread C K Kashyap
Thanks Alex,
I was thinking of increased memory space - not exactly doubling -  I was
thinking it would just be one additional byte per CELL. Ofcourse this
additional byte would not have the same lifetime of the CELL so it should
not need any extra management.

I feel encouraged - I'll give it a try :)

Regards,
Kashyap

On Tue, Apr 21, 2020 at 10:11 PM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > About the the CELL having an additional byte, I meant that the CELL size
> > would be 2*WORD + 1... that should work too right? I would not need any
> > masking in that case.
>
> I see. Yes, that would work. But it would either double the memory usage,
> or
> require some management of this additional byte (e.g. in a separate,
> parallel
> byte heap), which complicates things a lot more than it benefits.
>
> ☺/ A!ex
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: MiniPicolisp Questions

2020-04-21 Thread Alexander Burger
Hi Kashyap,

> About the the CELL having an additional byte, I meant that the CELL size
> would be 2*WORD + 1... that should work too right? I would not need any
> masking in that case.

I see. Yes, that would work. But it would either double the memory usage, or
require some management of this additional byte (e.g. in a separate, parallel
byte heap), which complicates things a lot more than it benefits.

☺/ A!ex


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


Re: MiniPicolisp Questions

2020-04-21 Thread C K Kashyap
Thanks Alex,
Yup, I can see what's going on now about RAM vs ROM :)

About the the CELL having an additional byte, I meant that the CELL size
would be 2*WORD + 1... that should work too right? I would not need any
masking in that case.

Regards,
Kashyap


On Mon, Apr 20, 2020 at 11:06 PM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > 1. About RAM vs ROM. Call me lazy but I would really appreciate a
> > description of how the RAM vs ROM decision is taken here (and in general
> > too..I mean, it is not clear to me how gen3m.c determines how something
> is
> > never written to or not)
> > if (x > 0)
> >Rom[x] = strdup(buf);
> > else
> >Ram[-x] = strdup(buf);
>
> The sign of 'x' is determined when reading the symbol, in the functions
> romSym()
> and ramSym().
>
> You can see where something gets stored to by whether RomIx or RamIx is
> used.
> Cell data all go to ROM, most symbol value cells to RAM (except some
> constants
> like NIL or T). This allows also symbols in ROM to be redefined at runtime.
>
>
> > 2. Can I try and make the CELL have an additional byte to store the TYPE
> > and get rid using tagged pointers? Clearly, it would be less efficient at
> > runtime but perhaps it would be more easy to understand. Is there any
> > reason that this would not work?
>
> No, this would work. You could use the most significant byte, but have to
> mask
> it when using the pointer (and live with the decreased address space size
> ;)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: MiniPicolisp Questions

2020-04-21 Thread Guido Stepken
Hi Kashyap!

Dividing up Lisp Cells (Atoms) in RAM/ROM - i think, you're referring to
this: https://picolisp.com/wiki/-A265.html has recently got another aspect:
https://en.wikipedia.org/wiki/Remote_direct_memory_access

RDMA, Remote Direct Memory Access.

With Picolisp and especially miniPicoLisp you can build one (logically)
giant Lisp machine across hundreds of servers. I'm using that since a
couple of weeks now using some Nokia 400 GbE cards and i must say: It works
pretty well! ;-)

Distributed in memory database, partly with persistance, Graph, PILOG on
top ...

It's the simlicity in PicoLisp that allows to do unbelievable things.

As i've already said: PicoLisp is a *genius strike*. You can easily do
things, that only would be available if you would use those multi million
line US software stacks, with all their bugs, NSA backdoors, whatever.

Have fun!

Best, Guido Stepken

Am Dienstag, 21. April 2020 schrieb C K Kashyap :
> Hi Alex et al,
> I've been working on miniPicoLisp source with the idea of making it more
easy to understand - granted, it's really simple but it's simplicity may
not be apparent from looking at the source to some (such as myself). For
instance, it took me some time to get what's going on with the optimized
string storage. So, one of the changes I did was to switch to 7 bits for
all. So I am trying to alter the code to make it easy for guys like me :)
> I have a couple of questions
> 1. About RAM vs ROM Call me lazy but I would really appreciate a
description of how the RAM vs ROM decision is taken here (and in general
too..I mean, it is not clear to me how gen3m.c determines how something is
never written to or not)
> if (x > 0)
>Rom[x] = strdup(buf);
> else
>Ram[-x] = strdup(buf);
>
> 2. Can I try and make the CELL have an additional byte to store the TYPE
and get rid using tagged pointers? Clearly, it would be less efficient at
runtime but perhaps it would be more easy to understand. Is there any
reason that this would not work?
> Regards,
> Kashyap


Re: MiniPicolisp Questions

2020-04-20 Thread Alexander Burger
Hi Kashyap,

> 1. About RAM vs ROM. Call me lazy but I would really appreciate a
> description of how the RAM vs ROM decision is taken here (and in general
> too..I mean, it is not clear to me how gen3m.c determines how something is
> never written to or not)
> if (x > 0)
>Rom[x] = strdup(buf);
> else
>Ram[-x] = strdup(buf);

The sign of 'x' is determined when reading the symbol, in the functions romSym()
and ramSym().

You can see where something gets stored to by whether RomIx or RamIx is used.
Cell data all go to ROM, most symbol value cells to RAM (except some constants
like NIL or T). This allows also symbols in ROM to be redefined at runtime.


> 2. Can I try and make the CELL have an additional byte to store the TYPE
> and get rid using tagged pointers? Clearly, it would be less efficient at
> runtime but perhaps it would be more easy to understand. Is there any
> reason that this would not work?

No, this would work. You could use the most significant byte, but have to mask
it when using the pointer (and live with the decreased address space size ;)

☺/ A!ex

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



MiniPicolisp Questions

2020-04-20 Thread C K Kashyap
Hi Alex et al,
I've been working on miniPicoLisp source with the idea of making it more
easy to understand - granted, it's really simple but it's simplicity may
not be apparent from looking at the source to some (such as myself). For
instance, it took me some time to get what's going on with the optimized
string storage. So, one of the changes I did was to switch to 7 bits for
all. So I am trying to alter the code to make it easy for guys like me :)

I have a couple of questions

1. About RAM vs ROM. Call me lazy but I would really appreciate a
description of how the RAM vs ROM decision is taken here (and in general
too..I mean, it is not clear to me how gen3m.c determines how something is
never written to or not)
if (x > 0)
   Rom[x] = strdup(buf);
else
   Ram[-x] = strdup(buf);

2. Can I try and make the CELL have an additional byte to store the TYPE
and get rid using tagged pointers? Clearly, it would be less efficient at
runtime but perhaps it would be more easy to understand. Is there any
reason that this would not work?

Regards,
Kashyap


Re: More application development questions

2019-11-10 Thread C K Kashyap
Thanks a ton Alex!!! ... makes my Sunday perfect :)
Regards,
Kashyap

On Sun, Nov 10, 2019 at 8:40 AM Alexander Burger 
wrote:

> On Sun, Nov 10, 2019 at 08:23:07AM -0800, C K Kashyap wrote:
> > (html 0 Ttl "@lib.css" NIL
> > (action
> > (idForm "A" '(choTmp) 'nr '+Update T '(may Delete) '((: nr))
>
> Can you try first to change the nesting:
>
>(action
>   (html 0 "Some Title" "@lib.css" NIL
>   (idForm ...
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: More application development questions

2019-11-10 Thread Alexander Burger
On Sun, Nov 10, 2019 at 08:23:07AM -0800, C K Kashyap wrote:
> (html 0 Ttl "@lib.css" NIL
> (action
> (idForm "A" '(choTmp) 'nr '+Update T '(may Delete) '((: nr))

Can you try first to change the nesting:

   (action
  (html 0 "Some Title" "@lib.css" NIL
  (idForm ...

☺/ A!ex

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


Re: More application development questions

2019-11-10 Thread C K Kashyap
Thanks Alex,
Here's what my tsk.l looks like now. I am not sure what the  search
function needs to be because I'd like to handle the incoming Object - The
following code does seem to render the form with the right object. However,
when I click on "edit" I get a 303. Also, clicking on the scroll button
causes a seg fault :(

(html 0 Ttl "@lib.css" NIL

(action

(idForm "A" '(choTmp) 'nr '+Update T '(may Delete) '((: nr))

(gui '(+Set +E/R +Chart) '((L) (filter bool L)) '(upds .  *ID)
3

'( (U I) (with U (list (: dsc) (: dt) (: tm) ) ))

'( (A B) (out "+/tmp/debug.txt" (prinl A B)))

)

( 'chart NIL

'(("em7" "Updates") ("em7" "Date") ("em7" "Time") )

(do 4

( (alternating)

(gui 1 '(+TextField) 100)

(gui 2 '(+DateField) 100)

(gui 3 '(+TimeField) 100)

)

 )

 )

 (scroll 4)

)

)

)


(de choTmp (X)

(out "+/tmp/dummy.txt"  (prinl X)))

Regards,
Kashyap


On Sun, Nov 10, 2019 at 1:45 AM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > After getting my todo app to work by editing the sample app I wanted to
> try
> > out a standalone version just to see if I understood all the moving
> parts.
> > I have two files
> >  -
> > todo.l (the main file) and tsk.l
>
> Good
>
>
> > (html 0 Ttl "@lib.css" NIL
> > (form NIL
> > (gui '(+Set +E/R +Chart) '((L) (filter bool L)) '(upds .  *ID)  3
>
> Using the global '*ID' in this way is not a good idea, as it is valid only
> directly in the GET transaction of the page, but not during further events
> (button press updates (POSTs)).
>
> The form has to keep the object locally. Normally this is in the 'obj'
> property
> of the form object (and then accessed with (: home obj) in GUI
> components). The
> most convenient way is to use 'idForm' instead of plain 'form'; it takes
> care to
> maintain the object properly.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: More application development questions

2019-11-10 Thread Alexander Burger
Hi Kashyap,

> After getting my todo app to work by editing the sample app I wanted to try
> out a standalone version just to see if I understood all the moving parts.
> I have two files
>  -
> todo.l (the main file) and tsk.l

Good


> (html 0 Ttl "@lib.css" NIL
> (form NIL
> (gui '(+Set +E/R +Chart) '((L) (filter bool L)) '(upds .  *ID)  3

Using the global '*ID' in this way is not a good idea, as it is valid only
directly in the GET transaction of the page, but not during further events
(button press updates (POSTs)).

The form has to keep the object locally. Normally this is in the 'obj' property
of the form object (and then accessed with (: home obj) in GUI components). The
most convenient way is to use 'idForm' instead of plain 'form'; it takes care to
maintain the object properly.

☺/ A!ex

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


More application development questions

2019-11-09 Thread C K Kashyap
Hi Alex,

After getting my todo app to work by editing the sample app I wanted to try
out a standalone version just to see if I understood all the moving parts.
I have two files
 -
todo.l (the main file) and tsk.l

tsk.l displays the tasks as expected (I have tsk.l inline for your
convenience)
(html 0 Ttl "@lib.css" NIL
(form NIL
(gui '(+Set +E/R +Chart) '((L) (filter bool L)) '(upds .  *ID)  3
'( (U I) (with U (list (: dsc) (: dt) (: tm) ) ))
'( (A B) (out "+/tmp/debug.txt" (prinl A B)))
)
( 'chart NIL
'(("em7" "Updates") ("em7" "Date") ("em7" "Time") )
(do 4
( (alternating)
(gui 1 '(+TextField) 100)
(gui 2 '(+DateField) 100)
(gui 3 '(+TimeField) 100)
)
 )
 )
 (scroll 4)
)
)

However when I try to click on the scroll button or edit fields in the form
I get this error -

: [tsk.l:1] !? (inc '*Form)

"3" -- Number expected

?

Can you please tell me what's going on here? Also, are there tips for
debugging such scenarios?

Regards,
Kashyap


Re: Version number questions

2019-09-15 Thread r cs
Simple and straight forward -- thanks, Alex!

On Sun, Sep 15, 2019 at 7:12 AM Alexander Burger 
wrote:

> On Sun, Sep 15, 2019 at 06:37:56AM -0400, r cs wrote:
> > Does the existence of separate "local" (19.7.5) and "rolling" (19.9.15)
> > release download on the website imply a stable vs. development release?
>
> No, they are both considered "stable". It is just that every half year a
> *snapshot* is taken, for the purpose of delivering it to Debian (and thus
> other
> distributions).
>
>
> > Is the filename of the local download, picoLisp-19.6.tgz
> > , supposed to reflect the
> > version number inside the tgz (now 19.7 and not 19.6) ?
>
> Yes, simply year and month. 19.6 had been delayed a few days, so that
> changes
> from July crawled in.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


-- 
*Níl aon tinteán mar do thinteán féin. *[Irish Gaelic]
(There is no fireside like your own fireside.)


Re: Version number questions

2019-09-15 Thread Alexander Burger
On Sun, Sep 15, 2019 at 06:37:56AM -0400, r cs wrote:
> Does the existence of separate "local" (19.7.5) and "rolling" (19.9.15)
> release download on the website imply a stable vs. development release?

No, they are both considered "stable". It is just that every half year a
*snapshot* is taken, for the purpose of delivering it to Debian (and thus other
distributions).


> Is the filename of the local download, picoLisp-19.6.tgz
> , supposed to reflect the
> version number inside the tgz (now 19.7 and not 19.6) ?

Yes, simply year and month. 19.6 had been delayed a few days, so that changes
from July crawled in.

☺/ A!ex

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


Version number questions

2019-09-15 Thread r cs
Does the existence of separate "local" (19.7.5) and "rolling" (19.9.15)
release download on the website imply a stable vs. development release?

Is the filename of the local download, picoLisp-19.6.tgz
, supposed to reflect the
version number inside the tgz (now 19.7 and not 19.6) ?

Thanks,
rcs

-- 
*Níl aon tinteán mar do thinteán féin. *[Irish Gaelic]
(There is no fireside like your own fireside.)


Re: General Lisp questions

2019-03-19 Thread Alexander Burger
Hi Yiorgos,

On Tue, Mar 19, 2019 at 03:46:34PM +0200, Yiorgos [George] Adamopoulos wrote:
> On Tue, Mar 19, 2019 at 3:37 PM Alexander Burger  wrote:
> >
> > Hi Kashyap,
> >
> > > Is LISP indeed List Integer and Symbol Processing? According to a lot of
> > > places on the web it seems to be just List Processing.
> >
> > Interesting! I never heard that. I always heard it means just "List 
> > Processing".
> > Integers are probably not an outstanding feature, every language has it.
> >
> 
> I think the question stems from what is written in the Picolisp FAQ:
> 
> "Simplicity
> 
> PicoLisp is easy to understand and adapt. There is no compiler
> enforcing special rules, and the interpreter is simple and
> straightforward. There are only three data types: Numbers, symbols and
> lists ("LISP" means "List-, Integer- and Symbol Processing" after all

Oohh, indeed! Forgot about that. ;)

☺/ A!ex

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


Re: General Lisp questions

2019-03-19 Thread C K Kashyap
Thanks Alex and Yiogros,
Incidentally I had "skip seen" the video before but I missed the CAR/CDR
explanation at 29:00 :) ... Feels good to know it finally!
Regards,
Kashyap

On Tue, Mar 19, 2019 at 6:53 AM Yiorgos [George] Adamopoulos <
yiorgos.adamopou...@gmail.com> wrote:

> On Tue, Mar 19, 2019 at 3:37 PM Alexander Burger 
> wrote:
> >
> > Hi Kashyap,
> >
> > > Is LISP indeed List Integer and Symbol Processing? According to a lot
> of
> > > places on the web it seems to be just List Processing.
> >
> > Interesting! I never heard that. I always heard it means just "List
> Processing".
> > Integers are probably not an outstanding feature, every language has it.
> >
>
> I think the question stems from what is written in the Picolisp FAQ:
>
> "Simplicity
>
> PicoLisp is easy to understand and adapt. There is no compiler
> enforcing special rules, and the interpreter is simple and
> straightforward. There are only three data types: Numbers, symbols and
> lists ("LISP" means "List-, Integer- and Symbol Processing" after all
> ;-). The memory footprint is minimal, and the tarball size of the
> whole system is just a few hundred kilobytes."
>
> The only other reference for this is
>
> https://groups.google.com/forum/#!msg/comp.lang.lisp/YSTxR0ycG5k/HiwBRjA1FNcJ
>
> >
> > > What is the history behind the names CAR and CDR?
> >
> > It goes back to the assembly language of some old IBM mainframe, meaning
> > "contents of address register" and "contents of decrement register".
> >
>
> Yes. A fun place where this is explained is this talk
>
> https://www.youtube.com/watch?v=hGY3uBHVVr4
>
> --
> keep raising the bar
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: General Lisp questions

2019-03-19 Thread Yiorgos [George] Adamopoulos
On Tue, Mar 19, 2019 at 3:37 PM Alexander Burger  wrote:
>
> Hi Kashyap,
>
> > Is LISP indeed List Integer and Symbol Processing? According to a lot of
> > places on the web it seems to be just List Processing.
>
> Interesting! I never heard that. I always heard it means just "List 
> Processing".
> Integers are probably not an outstanding feature, every language has it.
>

I think the question stems from what is written in the Picolisp FAQ:

"Simplicity

PicoLisp is easy to understand and adapt. There is no compiler
enforcing special rules, and the interpreter is simple and
straightforward. There are only three data types: Numbers, symbols and
lists ("LISP" means "List-, Integer- and Symbol Processing" after all
;-). The memory footprint is minimal, and the tarball size of the
whole system is just a few hundred kilobytes."

The only other reference for this is
https://groups.google.com/forum/#!msg/comp.lang.lisp/YSTxR0ycG5k/HiwBRjA1FNcJ

>
> > What is the history behind the names CAR and CDR?
>
> It goes back to the assembly language of some old IBM mainframe, meaning
> "contents of address register" and "contents of decrement register".
>

Yes. A fun place where this is explained is this talk

https://www.youtube.com/watch?v=hGY3uBHVVr4

-- 
keep raising the bar

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


Re: General Lisp questions

2019-03-19 Thread Alexander Burger
Hi Kashyap,

> Is LISP indeed List Integer and Symbol Processing? According to a lot of
> places on the web it seems to be just List Processing.

Interesting! I never heard that. I always heard it means just "List Processing".
Integers are probably not an outstanding feature, every language has it.


> What is the history behind the names CAR and CDR?

It goes back to the assembly language of some old IBM mainframe, meaning
"contents of address register" and "contents of decrement register".

☺/ A!ex

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


General Lisp questions

2019-03-19 Thread C K Kashyap
Hi Alex,
Is LISP indeed List Integer and Symbol Processing? According to a lot of
places on the web it seems to be just List Processing.

What is the history behind the names CAR and CDR?

Regards,
Kashyap


Re: A few questions from a confused lisper

2018-07-13 Thread Johan Persson

On 2018-07-13 05:25, Bruno Franco wrote:

actually, you could just put the function (mumble-mumble X) in the 
place

of Y:

(for X (1 2 3 4 5)
(NIL (mumble-mumble X)
(println "this does not work")) )


Sure, but this doesn't help if I wish to use Y in multiple places...



On Thu, Jul 12, 2018 at 9:27 PM Bruno Franco 
 wrote:


Well, for the conditional exit in the iterators (for, do, and loop),
I would do something like this:
(use Y
(for X (1 2 3 4 5)
(setq Y (mumble-mumble X))
(NIL Y (println "this does not work")) ) )


Good to know! In other words, conditional exits need to be a part of the 
for-do-loop-bodies, and not nested.




Though I'm not sure that is the most elegant way to go XD.


Elegance is a distraction :)


As for the local exits, maybe an example of when you wanted to do one
in picolisp would be useful to point you in the right direction.

And the macros, here's a page that can help you find your way
around not having them:
https://picolisp.com/wiki/?macros

also see the functions 'fill and 'macro.
'fill replaces each occurence of a pattern @Pat with its value in the
list that you give it, and 'macro does the same, but evaluates the
resulting list too.

Hope this helps!


Thanks, I replied to this in abu's reply.

On Thu, Jul 12, 2018 at 1:34 PM Johan Persson  wrote: 
Hi, list!


First I'd like to say that I'm having a blast playing around with
PicoLisp lately. (It only took me about seven years to get around to
it!) The fact that it exists and work as well as it does is a fresh and
bold counterpoint to the conventional wisdom of the current programming
language design canon. I love it.

Anyhow, there are a few things that the Common Lisper in me find a bit
puzzling:

First off, I'm confused about what the correct way of doing local exits
There's no "return" or "return-from" -- instead the closest thing I've
found is "quit", which is sort of akin to "error" in CL, but without 
the

jump into the condition-system. It feels wrong. Is it wrong?

Then there's the conditional exits in "for", "do" and "loop" which
presents a real problem if you wish to terminate the loop from within a
sub-clause:

(for X (1 2 3 4 5)
(let Y (mumble-mumble X)
(NIL Y (println "this doesn't work"

What's the correct way of doing this? Throw the value and catch it 
right

outside of the for-loop?

I'm also a pathological meta-programmer, and the lack of macros doesn't
bother me as much as I thought it would. However, one thing I miss from
other lisps is a way of expanding macros. How would I go on about doing
that in PicoLisp?

/ Johan

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


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


Re: A few questions from a confused lisper

2018-07-13 Thread Johan Persson

On 2018-07-13 07:19, Alexander Burger wrote:

Hi Johan,

First off, I'm confused about what the correct way of doing local 
exits.
There's no "return" or "return-from" -- instead the closest thing I've 
found

is "quit", which is sort of akin to "error" in CL


Correct. There is no 'return' function jumping directly out of a nested
structure. There are, however, 'catch' and 'throw', which implement the 
same
mechanism (cleaning up all necessary stuff before doing the exit) - 
just not

syntactically as neat as a simple 'return'.

I use NIL as the catch tag in such cases, e.g.

   (de foo (Args)
  (catch NIL
 (while (something)
(let (A (bar)  B (mumble))
   (racker
  (for I A
 (when (lt0 (+ I B))
(throw) ) ) ) ) ) ) )

Here (throw) corresponds to a (return).

To return a value like (return 7) do (throw NIL 7).


The reason for not having a 'return' function is that it has to do a 
lot of
cleanup till it reaches the exit (unbind variables, close files and 
other

dynamic environments). This is initialized and set up by 'catch'.

When a function starts to run, the interpreter does not know yet that 
there
might be a call to 'return' somewhere deeply nested inside. So it would 
need to
setup the catch environment for *every* function. This would be too 
expensive,

as most functions will never call 'return'.

Instead, it is done the PicoLisp way: Let the programmer be in control! 
Just
insert '(catch NIL' at the beginning of a function (or at any other 
place).


If you insist, you can create your own return function:

   (de return (Val)
  (throw NIL Val) )

The '(catch NIL' is still needed though.


'quit' is similar to 'throw'. It throws an error message instead of a 
tag, and
is triggered internally also when an error occurs, which then can be 
caught with

'(catch '("Message 1" "Message 2") ...




I see, that makes a lot of sense. I generally expect stuff that is being 
thrown to include a hefty payload of stack traces, environments and 
other assorted guff. This approach is what I hoped for. :)




Then there's the conditional exits in "for", "do" and "loop" which 
presents
a real problem if you wish to terminate the loop from within a 
sub-clause:


(for X (1 2 3 4 5)
  (let Y (mumble-mumble X)
 (NIL Y (println "this doesn't work"


Yes. As also pointed out by Bruno, the 'T' and 'NIL' exit clauses must 
be on the

top level of the body. Usually code can be rearranged this way. If not,
catch/throw can be used here too.




Fair enough.

I'm also a pathological meta-programmer, and the lack of macros 
doesn't
bother me as much as I thought it would. However, one thing I miss 
from
other lisps is a way of expanding macros. How would I go on about 
doing that

in PicoLisp?


For one thing, there are read-macros which are expanded at read-time.

Then, there is - also pointed out by Bruno - 'fill' and 'macro' which 
may
be used to build and execute expressions at runtime. 'macro' is rather 
seldom

used, as it introduces quite some overhead in an interpreted system.

The way to go for meta-programming is to use FEXPRs. Examples are many 
in the
PicoLisp package itself, or at 
https://software-lab.de/doc/faq.html#macros or

http://rosettacode.org/wiki/Extend_your_language#PicoLisp



Oh, I know of all these things. (Though I don't have an appreciation for 
how heavy "macro" is.) My problem -- I guess -- is that I have a 
thoroughly ingrained idea of how meta-programming is supposed to behave 
in a lisp. For instance, expanding macros makes sense in a language that 
makes a distinction between macros and functions, but a language that 
support FEXPRs I guess it's not that clear. From what I gather, I need 
to shift mental gears here and not try to push a square peg into a round 
hole.
Though, Bruno's suggestion of using "fill" is a great idea for 
"macro-expanding" as one is coding along.


Thanks for the replies! :)


—Alex


/ Johan

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


Re: A few questions from a confused lisper

2018-07-12 Thread Alexander Burger
Hi Johan,

> First off, I'm confused about what the correct way of doing local exits.
> There's no "return" or "return-from" -- instead the closest thing I've found
> is "quit", which is sort of akin to "error" in CL

Correct. There is no 'return' function jumping directly out of a nested
structure. There are, however, 'catch' and 'throw', which implement the same
mechanism (cleaning up all necessary stuff before doing the exit) - just not
syntactically as neat as a simple 'return'.

I use NIL as the catch tag in such cases, e.g.

   (de foo (Args)
  (catch NIL
 (while (something)
(let (A (bar)  B (mumble))
   (racker
  (for I A
 (when (lt0 (+ I B))
(throw) ) ) ) ) ) ) )

Here (throw) corresponds to a (return).

To return a value like (return 7) do (throw NIL 7).


The reason for not having a 'return' function is that it has to do a lot of
cleanup till it reaches the exit (unbind variables, close files and other
dynamic environments). This is initialized and set up by 'catch'.

When a function starts to run, the interpreter does not know yet that there
might be a call to 'return' somewhere deeply nested inside. So it would need to
setup the catch environment for *every* function. This would be too expensive,
as most functions will never call 'return'.

Instead, it is done the PicoLisp way: Let the programmer be in control! Just
insert '(catch NIL' at the beginning of a function (or at any other place).

If you insist, you can create your own return function:

   (de return (Val)
  (throw NIL Val) )

The '(catch NIL' is still needed though.


'quit' is similar to 'throw'. It throws an error message instead of a tag, and
is triggered internally also when an error occurs, which then can be caught with
'(catch '("Message 1" "Message 2") ...



> Then there's the conditional exits in "for", "do" and "loop" which presents
> a real problem if you wish to terminate the loop from within a sub-clause:
> 
> (for X (1 2 3 4 5)
>   (let Y (mumble-mumble X)
>  (NIL Y (println "this doesn't work"

Yes. As also pointed out by Bruno, the 'T' and 'NIL' exit clauses must be on the
top level of the body. Usually code can be rearranged this way. If not,
catch/throw can be used here too.


> I'm also a pathological meta-programmer, and the lack of macros doesn't
> bother me as much as I thought it would. However, one thing I miss from
> other lisps is a way of expanding macros. How would I go on about doing that
> in PicoLisp?

For one thing, there are read-macros which are expanded at read-time.

Then, there is - also pointed out by Bruno - 'fill' and 'macro' which may
be used to build and execute expressions at runtime. 'macro' is rather seldom
used, as it introduces quite some overhead in an interpreted system.

The way to go for meta-programming is to use FEXPRs. Examples are many in the
PicoLisp package itself, or at https://software-lab.de/doc/faq.html#macros or
http://rosettacode.org/wiki/Extend_your_language#PicoLisp

—Alex

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


Re: A few questions from a confused lisper

2018-07-12 Thread Bruno Franco
actually, you could just put the function (mumble-mumble X) in the place
of Y:
(for X (1 2 3 4 5)
(NIL (mumble-mumble X)
(println "this does not work")) )


On Thu, Jul 12, 2018 at 9:27 PM Bruno Franco 
wrote:

> Well, for the conditional exit in the iterators (for, do, and loop),
> I would do something like this:
> (use Y
> (for X (1 2 3 4 5)
> (setq Y (mumble-mumble X))
> (NIL Y (println "this does not work")) ) )
>
> Though I'm not sure that is the most elegant way to go XD.
>
> As for the local exits, maybe an example of when you wanted to do one
> in picolisp would be useful to point you in the right direction.
>
> And the macros, here's a page that can help you find your way
> around not having them:
> https://picolisp.com/wiki/?macros
>
> also see the functions 'fill and 'macro.
> 'fill replaces each occurence of a pattern @Pat with its value in the
> list that you give it, and 'macro does the same, but evaluates the
> resulting list too.
>
> Hope this helps!
>
>
> On Thu, Jul 12, 2018 at 1:34 PM Johan Persson  wrote:
>
>> Hi, list!
>>
>> First I'd like to say that I'm having a blast playing around with
>> PicoLisp lately. (It only took me about seven years to get around to
>> it!) The fact that it exists and work as well as it does is a fresh and
>> bold counterpoint to the conventional wisdom of the current programming
>> language design canon. I love it.
>>
>> Anyhow, there are a few things that the Common Lisper in me find a bit
>> puzzling:
>>
>> First off, I'm confused about what the correct way of doing local exits.
>> There's no "return" or "return-from" -- instead the closest thing I've
>> found is "quit", which is sort of akin to "error" in CL, but without the
>> jump into the condition-system. It feels wrong. Is it wrong?
>>
>> Then there's the conditional exits in "for", "do" and "loop" which
>> presents a real problem if you wish to terminate the loop from within a
>> sub-clause:
>>
>>  (for X (1 2 3 4 5)
>>(let Y (mumble-mumble X)
>>   (NIL Y (println "this doesn't work"
>>
>> What's the correct way of doing this? Throw the value and catch it right
>> outside of the for-loop?
>>
>> I'm also a pathological meta-programmer, and the lack of macros doesn't
>> bother me as much as I thought it would. However, one thing I miss from
>> other lisps is a way of expanding macros. How would I go on about doing
>> that in PicoLisp?
>>
>> / Johan
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: A few questions from a confused lisper

2018-07-12 Thread Bruno Franco
Well, for the conditional exit in the iterators (for, do, and loop),
I would do something like this:
(use Y
(for X (1 2 3 4 5)
(setq Y (mumble-mumble X))
(NIL Y (println "this does not work")) ) )

Though I'm not sure that is the most elegant way to go XD.

As for the local exits, maybe an example of when you wanted to do one
in picolisp would be useful to point you in the right direction.

And the macros, here's a page that can help you find your way
around not having them:
https://picolisp.com/wiki/?macros

also see the functions 'fill and 'macro.
'fill replaces each occurence of a pattern @Pat with its value in the
list that you give it, and 'macro does the same, but evaluates the
resulting list too.

Hope this helps!


On Thu, Jul 12, 2018 at 1:34 PM Johan Persson  wrote:

> Hi, list!
>
> First I'd like to say that I'm having a blast playing around with
> PicoLisp lately. (It only took me about seven years to get around to
> it!) The fact that it exists and work as well as it does is a fresh and
> bold counterpoint to the conventional wisdom of the current programming
> language design canon. I love it.
>
> Anyhow, there are a few things that the Common Lisper in me find a bit
> puzzling:
>
> First off, I'm confused about what the correct way of doing local exits.
> There's no "return" or "return-from" -- instead the closest thing I've
> found is "quit", which is sort of akin to "error" in CL, but without the
> jump into the condition-system. It feels wrong. Is it wrong?
>
> Then there's the conditional exits in "for", "do" and "loop" which
> presents a real problem if you wish to terminate the loop from within a
> sub-clause:
>
>  (for X (1 2 3 4 5)
>(let Y (mumble-mumble X)
>   (NIL Y (println "this doesn't work"
>
> What's the correct way of doing this? Throw the value and catch it right
> outside of the for-loop?
>
> I'm also a pathological meta-programmer, and the lack of macros doesn't
> bother me as much as I thought it would. However, one thing I miss from
> other lisps is a way of expanding macros. How would I go on about doing
> that in PicoLisp?
>
> / Johan
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


A few questions from a confused lisper

2018-07-12 Thread Johan Persson

Hi, list!

First I'd like to say that I'm having a blast playing around with 
PicoLisp lately. (It only took me about seven years to get around to 
it!) The fact that it exists and work as well as it does is a fresh and 
bold counterpoint to the conventional wisdom of the current programming 
language design canon. I love it.


Anyhow, there are a few things that the Common Lisper in me find a bit 
puzzling:


First off, I'm confused about what the correct way of doing local exits. 
There's no "return" or "return-from" -- instead the closest thing I've 
found is "quit", which is sort of akin to "error" in CL, but without the 
jump into the condition-system. It feels wrong. Is it wrong?


Then there's the conditional exits in "for", "do" and "loop" which 
presents a real problem if you wish to terminate the loop from within a 
sub-clause:


(for X (1 2 3 4 5)
  (let Y (mumble-mumble X)
 (NIL Y (println "this doesn't work"

What's the correct way of doing this? Throw the value and catch it right 
outside of the for-loop?


I'm also a pathological meta-programmer, and the lack of macros doesn't 
bother me as much as I thought it would. However, one thing I miss from 
other lisps is a way of expanding macros. How would I go on about doing 
that in PicoLisp?


/ Johan

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


Re: Two questions regarding 'native'

2017-10-24 Thread Alexander Williams

This looks pretty good.

If it helps, I've written a few 'native' tutorials, at 
https://picolisp.a1w.ca


+1 for choosing a liberal license as well (CC0).


AW

On 17-10-24 11:06 AM, Alfonso Villén wrote:


I've created a public Bitbucket repository with my work so far,
including some examples.
https://bitbucket.org/alfonsovillen/picolispffi


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


Re: Two questions regarding 'native'

2017-10-24 Thread Alfonso Villén
Hello Mike,

I've just made the Reddit post:
https://www.reddit.com/r/lisp/comments/78iy7w/sdl2_and_opengl_33_on_picolisp_64bit/

2017-10-24 13:35 GMT+02:00 Mike Pechkin :

> ​Alfonso,
>
> Make a post on reddit.com/r/lisp​
>
>
>
>
>> I've created a public Bitbucket repository with my work so far, including
>> some examples.
>> https://bitbucket.org/alfonsovillen/picolispffi
>>
>> I don't know if someone will be interested in it, but I'm having fun
>> doing it.
>>
>
>


Re: Two questions regarding 'native'

2017-10-24 Thread Mike Pechkin
​Alfonso,

Make a post on reddit.com/r/lisp​




> I've created a public Bitbucket repository with my work so far, including
> some examples.
> https://bitbucket.org/alfonsovillen/picolispffi
>
> I don't know if someone will be interested in it, but I'm having fun doing
> it.
>


Re: Two questions regarding 'native'

2017-10-24 Thread Alfonso Villén
Hello,

finally, I could display a triangle using OpenGL 3.3. I translated the code
from the C tutorial at:
https://learnopengl.com/#!Getting-started/Hello-Triangle.

Thanks again for your help, Alex.

Unfortunately I'm running into difficulties again because after translating
the next tutorial, nothing is rendered. Maybe I'll post a question about it
later.

I've created a public Bitbucket repository with my work so far, including
some examples.
https://bitbucket.org/alfonsovillen/picolispffi

I don't know if someone will be interested in it, but I'm having fun doing
it.

Bye,
Alfonso V.

2017-10-21 15:34 GMT+02:00 Alexander Burger :

> On Sat, Oct 21, 2017 at 02:38:18PM +0200, Alfonso Villén wrote:
> > The function arguments don't work as you expected. That C function needs
> > some weird information such as an array of integers giving the length of
> > the strings in the other array if those don't end with null bytes...
>
> Ah, I see. Didn't know that. Then it is probably something like:
>
>
>(de glShaderSource (Shader Strings)
>   (let
>  (Lst
> (mapcar
>'((Str) (cons (native "@" "strdup" 'N Str) 8))
>Strings )
> Len (length Strings) )
>  (native `*GlutLib "glShaderSource" NIL
> Shader
> Len
> (cons NIL (list (* 8 Len)) Lst)
> (cons NIL (list (* 8 Len))
>(mapcar
>   '((Str) (- (length Str)))
>   Strings ) ) )
>  (mapc '((X) (native "@" "free" NIL (car X))) Lst) ) )
>
>
> > I'm also having problems with other function, and in all of them there
> are
> > pointer arguments involved. But I hope I'll be able to figure the
> solution
> > myself.
> >
> > When I get some examples working I'd like to share the code with you all.
>
> Great, thanks! Perhaps we can add them to @lib/openGl.l then.
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Two questions regarding 'native'

2017-10-21 Thread Alexander Burger
On Sat, Oct 21, 2017 at 02:38:18PM +0200, Alfonso Villén wrote:
> The function arguments don't work as you expected. That C function needs
> some weird information such as an array of integers giving the length of
> the strings in the other array if those don't end with null bytes...

Ah, I see. Didn't know that. Then it is probably something like:


   (de glShaderSource (Shader Strings)
  (let
 (Lst
(mapcar
   '((Str) (cons (native "@" "strdup" 'N Str) 8))
   Strings )
Len (length Strings) )
 (native `*GlutLib "glShaderSource" NIL
Shader
Len
(cons NIL (list (* 8 Len)) Lst)
(cons NIL (list (* 8 Len))
   (mapcar
  '((Str) (- (length Str)))
  Strings ) ) )
 (mapc '((X) (native "@" "free" NIL (car X))) Lst) ) )


> I'm also having problems with other function, and in all of them there are
> pointer arguments involved. But I hope I'll be able to figure the solution
> myself.
> 
> When I get some examples working I'd like to share the code with you all.

Great, thanks! Perhaps we can add them to @lib/openGl.l then.

♪♫ Alex

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


Re: Two questions regarding 'native'

2017-10-21 Thread Alfonso Villén
Hello,

thank you very much, Alex. It seems to work, but I have to test more
thoroughly.

The function arguments don't work as you expected. That C function needs
some weird information such as an array of integers giving the length of
the strings in the other array if those don't end with null bytes...

I'm also having problems with other function, and in all of them there are
pointer arguments involved. But I hope I'll be able to figure the solution
myself.

When I get some examples working I'd like to share the code with you all.

Alfonso Villén

Am 21.10.2017 10:08 schrieb "Alexander Burger" :

> Hi Alfonso,
>
> > I'm exploring Picolisp as a hobby for a while now, and I find it
> absolutely
> > amazing. I'm experimenting with 'native', trying to make some bindings
> for
> > SDL2 and OpenGL.
>
> I assume you found the OpenGL library in the distribution too, right? Just
> for
> the records, it is in "@lib/openGl.l".
>
>
> > I want to call this OpenGL function with 'native':
> >
> > void glShaderSource(
> > GLuint shader,
> > GLsizei count,
> > const GLchar **string,
> > const GLint *length)
> >
> > I have a problem with the third argument. I can't figure out if and how a
> > pointer to an array of string pointers can be passed to the function
> using
> > 'native'.
>
> An array of string pointers basically boils down to a structure in C.
>
> However, this case is indeed tricky, because the string array must first be
> created. I would call strdup() to get a list of pointers.
>
> Assuming you have {"abc", "def", "ghi"), this would be
>
>(mapcar
>   '((Str) (cons (native "@" "strdup" 'N Str) 8))
>   '("abc" "def" "ghi") )
>
> That is, it creates a list (( . 8) ( . 8) ( .
> 8)).
> The '8' values are needed for the 'native' struct definition (as the
> reference
> says "a pair (num . cnt) where 'num' is stored in a field of 'cnt' bytes").
>
> Note that you must also call free() on the results of strdup() when done.
>
>
> > My other question is about the fourth argument. Is there a way (other
> than
> > allocating some memory with 'malloc') so you can pass a C pointer to a
> > Picolisp symbol's value using 'native'?
>
> You can pass a pointer simply as a number. But this doesn't make sense
> here,
> because where should that pointer come from?
>
> So one way is to call 'malloc' as you said, but you can better let
> 'native' do
> the alloction for you, as another structure which holds a single pointer
> and
> which returns its value. The following passes the number 3 in a
> single-element
> 'int' array, receiving the possibly modified value in the variable 'Len':
>
>(Len (8 . I) -3)
>
> If you are not interested in a return value, and just want to pass 3:
>
>(NIL (8) -3)
>
>
> With all that, your function would be:
>
>(de glShaderSource (Shader Count Strings)
>   (let
>  (Lst
> (mapcar
>'((Str) (cons (native "@" "strdup" 'N Str) 8))
>Strings )
> Len (length Lst) )
>  (native `*GlutLib "glShaderSource" NIL
> Shader
> Count
> (cons NIL (list (* 8 Len)) Lst)
> (list 'Len (8 . I) (- Len)) )
>  (mapc '((X) (native "@" "free" NIL (car X))) Lst)
>  Len ) )
>
> You call it as (glShaderSource 3 4 '("abc" "def" "ghi")).
>
> I haven't checked the OpenGL docs if this makes sense, and haven't tested
> the
> above. It assumes that 'length' holds the number of strings in 'string'
> (and not
> 'count'!). And it assumes that you want to return the length in 'Len'. So
> the
> above must perhaps be modified.
>
> Indeed rather messy ;)
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Two questions regarding 'native'

2017-10-21 Thread Alexander Burger
Hi Alfonso,

> I'm exploring Picolisp as a hobby for a while now, and I find it absolutely
> amazing. I'm experimenting with 'native', trying to make some bindings for
> SDL2 and OpenGL.

I assume you found the OpenGL library in the distribution too, right? Just for
the records, it is in "@lib/openGl.l".


> I want to call this OpenGL function with 'native':
> 
> void glShaderSource(
> GLuint shader,
> GLsizei count,
> const GLchar **string,
> const GLint *length)
> 
> I have a problem with the third argument. I can't figure out if and how a
> pointer to an array of string pointers can be passed to the function using
> 'native'.

An array of string pointers basically boils down to a structure in C.

However, this case is indeed tricky, because the string array must first be
created. I would call strdup() to get a list of pointers.

Assuming you have {"abc", "def", "ghi"), this would be

   (mapcar
  '((Str) (cons (native "@" "strdup" 'N Str) 8))
  '("abc" "def" "ghi") )

That is, it creates a list (( . 8) ( . 8) ( . 8)).
The '8' values are needed for the 'native' struct definition (as the reference
says "a pair (num . cnt) where 'num' is stored in a field of 'cnt' bytes").

Note that you must also call free() on the results of strdup() when done.


> My other question is about the fourth argument. Is there a way (other than
> allocating some memory with 'malloc') so you can pass a C pointer to a
> Picolisp symbol's value using 'native'?

You can pass a pointer simply as a number. But this doesn't make sense here,
because where should that pointer come from?

So one way is to call 'malloc' as you said, but you can better let 'native' do
the alloction for you, as another structure which holds a single pointer and
which returns its value. The following passes the number 3 in a single-element
'int' array, receiving the possibly modified value in the variable 'Len':

   (Len (8 . I) -3)

If you are not interested in a return value, and just want to pass 3:

   (NIL (8) -3)


With all that, your function would be:

   (de glShaderSource (Shader Count Strings)
  (let
 (Lst
(mapcar
   '((Str) (cons (native "@" "strdup" 'N Str) 8))
   Strings )
Len (length Lst) )
 (native `*GlutLib "glShaderSource" NIL
Shader
Count
(cons NIL (list (* 8 Len)) Lst)
(list 'Len (8 . I) (- Len)) )
 (mapc '((X) (native "@" "free" NIL (car X))) Lst)
 Len ) )

You call it as (glShaderSource 3 4 '("abc" "def" "ghi")).

I haven't checked the OpenGL docs if this makes sense, and haven't tested the
above. It assumes that 'length' holds the number of strings in 'string' (and not
'count'!). And it assumes that you want to return the length in 'Len'. So the
above must perhaps be modified.

Indeed rather messy ;)

♪♫ Alex

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


Two questions regarding 'native'

2017-10-20 Thread Alfonso Villén
Hello,

I'm exploring Picolisp as a hobby for a while now, and I find it absolutely
amazing. I'm experimenting with 'native', trying to make some bindings for
SDL2 and OpenGL.

I want to call this OpenGL function with 'native':

void glShaderSource(
GLuint shader,
GLsizei count,
const GLchar **string,
const GLint *length)

I have a problem with the third argument. I can't figure out if and how a
pointer to an array of string pointers can be passed to the function using
'native'.

My other question is about the fourth argument. Is there a way (other than
allocating some memory with 'malloc') so you can pass a C pointer to a
Picolisp symbol's value using 'native'?

I'd be very glad if someone could answer.

Alfonso Villén


Re: a bunch of questions about syntax

2017-02-01 Thread pd
thanks for your answers, Alex

On Sun, Jan 29, 2017 at 9:48 AM, Alexander Burger 
wrote:

>
> > >(if (testSomething) (doSomething1) (doSomething2) (doSomething3))
> > ...
> > but this also means the only way to indicate several executable
> expressions
> > in the "then-clause" is to surround them between parens, i.e.  (if (= 2
> 2)
> > ((print "equal") (print "2")) (print "not equal") (print "not 2"))   I
>
> No. This gives a crash (try it, and think about why ;).
>


I tried and it crashes with a segmentation fault, I was thinking about what
could be the reason and my guess is it is related with 'eval' function. I
think when the body of "if" function tries to eval the any2 expression it
fails with sementation fault if it is a list of lists, that is, the first
item of any2 expression is a list:

(eval 1)  -> 1
(eval (1)) -> (1)
(eval ((1)))  segmentation fault

My guess is eval tries to evaluate its parameter, thus when being a number
it evaluates to itself and an atom evaluates to its value:

(setq A 1)
(eval A) -> 1
(eval B) --- B is not defined

But when the parameter to evaluate is a list, eval tries to evaluate the
list which means to apply the function call represented by the list, with
special case of lists of numbers

(de f (X) (+ X 1))
(eval (f 1)) -> 2   # eval tries to evaluate the list viewed as a function
call so it applies function f to parameter 2 and gets the returned value as
the result of eval
(eval (1 2)) -> (1 2)  # the same as above but exploiting the special
treatment picolisp give to list of numbers in order to avoid quoting it

The problem appears when you pass eval a list of lists (or a list with a
first item which is also a list), in this case eval tries to evaluate but
doen't know how to eval a item list, it could be a function call because it
is not an atom. Using the analogy of stack when eval gets a simple list it
pops the first item which being an atom means it must be a function name so
two possible cases it's a defined function or it is not defined, if it is
defined but it's not a function but it also fails with segmentation fault
because you cannot apply an atom if it's not a function (and evaluating a
list means it must be a function call  --or a list of numbers--)

(de f (X) (* X X))
(setq A 1)
(eval (f 2)) -> 4
(eval (A 2)) --- segmentation fault
(eval f)  --- X undefined
(eval 'f)  -> ((X) (* X X))
(eval (f)) -> NIL # strangely in this case it doesn't say X undefined but
returns NIL

The problem seems to be only when eval expects an atom to be a function or
an undefined symbol and what it gets is an defined atom which is not a
function symbol:

(eval B) -> NIL
(eval (B)) --- B undefined
(eval (B 1)) --- B undefined
(eval ((B))) --- B undefined
(eval ((B 1))) --- B undefined
(setq B 2)
(eval B) -> 2
(eval (B)) --- segmentation fault
(eval (B 1)) --- segmentation fault
(eval ((B))) --- segmentation fault
(eval ((B 1))) --- segmentation fault

Also eval evaluates recursively the list passed as arguments

(de g (X) (+ X 1))
(de f (X) 'g)
(eval ((f 99) 2 )) -> 3

So my conclusion is eval always expect a list to be a valid function call
(or a list of numbers) and if it is not then fails with segmentation
fault.  And the reason for "if" to fail in a similar way is it tries to
eval the "then-clause" (any2)

If so what I don't understand is why to cause a segmentation fault, I think
it could easily avoid if eval phase in REPL simply detect a first item in a
list being a defined atom but not a function and throw an error (in a
similar way of "not defined" errors in previous examples) or even even
evaluating the atom to its value when it detects it is not a function (even
being the first item in a list).

What I mean is maybe a desiderable behaviour of eval would be:

(setq A 1)
(de f (N) (+ N 1))
(eval A) -> 1
(eval (f 1)) -> 2
(eval (A 2)) --- A is not a function  # case 1, eval knows it is not a
function
(eval (A 2)) -> 1   # case 2, even when it seems a function call since A is
not a function but a defined symbol resolve to its value
(eval ((A))) -> 1  # case 2, but could also be implemented as case 1 too

Is it my reasoning right?  or maybe I'm saying a nonsense?

Anyway I see the segmentation fault messages includes some numbers, are
they anyhow setted by picolisp or are they totally system dependent?

[1]863 segmentation fault  ./pil +
 ^ ^^^
 |__| this numbers


regards


Re: a bunch of questions about syntax

2017-01-29 Thread Alexander Burger
On Sat, Jan 28, 2017 at 09:55:14PM +0100, pd wrote:
> Thank you Alex for your patience, I see I have a severe confussion about
> how picolisp manages lists

No problem! It is good to discuss this here, as it may help others too.


> let's start by the begining... as far as I know   (f a b 4)  is just a list
> equivalent to (f . (a . (b . (4 . NIL  and the fact being also a
> function call to function f applying parameters a b 4 is just a matter of
> "convention", simply when picolisp evals a list with a first item not being
> a number it supposes it's a function call and tries to evaluate first item
> (it doesn't matter if first item is a symbol or another list, it gets
> evaluated) which is supposed to be evaluated to a function value

That's right.


> With this point of view I understand what you mean when saying  (f 1 a b c)
> is just the same as (f 1 . (a b c)) and thus you can view a, b, c as a list

Yes.


> so you can describe this funcion as (f num . 'lst), ok, but also I think
> ...
> you could describe the function f also as (f . 'lst) . The only difference

Yes, but without the quotes. As a function reference (f num . 'lst) is
impossible, as the quote indicates evaluation which is not handled by PicoLisp
this way.


> But if you describe a function like (g num 'lst) is a quite different thing
> because you are expecting two arguments the first one being a number and
> the second being a list (of unlimited number of items), really all

Yes.


> functions described have an unlimited number of arguments but function g
> packs all arguments but the first in a list.

No. This is not done by 'g'. This function *expects* a list after evaluating its
second argument.


> >(if (testSomething) (doSomething1) (doSomething2) (doSomething3))
> ...
> but this also means the only way to indicate several executable expressions
> in the "then-clause" is to surround them between parens, i.e.  (if (= 2 2)
> ((print "equal") (print "2")) (print "not equal") (print "not 2"))   I

No. This gives a crash (try it, and think about why ;).

The "then" clause must be a single expression. Typicaley you use 'prog'
if you need to call more than one expression here.


> appreciate here an absence of symmetry, you must pack all exe expressions

That's right.


> why not to define and describe function if in a symmetrical way as   (if
> 'any prg1 prg2)  even when not obeying parens economy?   (sure there is a
> good reason to do it that way simply I'm not able to see)

If 'if' were specified this way, it would lose its simplicity because you always
need additional nesting for the "then" clause.

For more complex conditional expressions, we use 'cond' instead of 'if'.


> - two functions f described this way:
> 
>(f num . lst)
>(f num1 num2)
> 
> then the list (f 1 2) is a valid call for both functions, the first f will
> bind first parameter to numer 1 and second parameter to list (2) (all
> remaining parameters as a list) while the second f will bind 1 to num1 and
> 2 to num2 (descarding empty list NIL).

Correct.

> My confusion here is picolisp must
> do two pops to bind parameters for a first f function call but three pops
> to bind parameters for a second f function call. How discriminate picolisp
> between each cases? I suppose the answer is function definition:
> 
> first f defined as (de f (X . Rest) (...) )
> second f defined as (de f (X Y) (...) )

Exactly. The interpreter finds either (X . Rest) or (X Y) when evaluating (f 1 
2),
so it knows what to do.

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


Re: a bunch of questions about syntax

2017-01-28 Thread pd
Thank you Alex for your patience, I see I have a severe confussion about
how picolisp manages lists

let's start by the begining... as far as I know   (f a b 4)  is just a list
equivalent to (f . (a . (b . (4 . NIL  and the fact being also a
function call to function f applying parameters a b 4 is just a matter of
"convention", simply when picolisp evals a list with a first item not being
a number it supposes it's a function call and tries to evaluate first item
(it doesn't matter if first item is a symbol or another list, it gets
evaluated) which is supposed to be evaluated to a function value

With this point of view I understand what you mean when saying  (f 1 a b c)
is just the same as (f 1 . (a b c)) and thus you can view a, b, c as a list
so you can describe this funcion as (f num . 'lst), ok, but also I think
you could describe the function f also as (f . 'lst) . The only difference
is that using the latter you are only interested in remark you pass to f a
sequence of symbols (which form a list) while using the former description
you are interested in remark the first symbol in the sequence is supposed
to be a number and also it is not evaluated.

But if you describe a function like (g num 'lst) is a quite different thing
because you are expecting two arguments the first one being a number and
the second being a list (of unlimited number of items), really all
functions described have an unlimited number of arguments but function g
packs all arguments but the first in a list.

I think I get the point, but what confuses me is when you say

On Sat, Jan 28, 2017 at 8:31 AM, Alexander Burger 
wrote:

> > From this point of view my question is about the difference of using or
> > > not using dot when describing a function, for example, take the if
> > > description:
> > >
> > > (if 'any1 any2 . prg) -> any
> > >
> > > Would the description below describe the same function?
> > >
> > > (if 'any1 any2 prg) -> any
>
> A typical call of 'if' could be
>
>(if (testSomething) (doSomething1) (doSomething2) (doSomething3))
>
> where
>
>any1 is the result of evaluating (testSomething)
>any2 is (doSomething1)
>prg is ((doSomething2) (doSomething3))
>
> Perhaps it helps understanding if we remember that
>
>(if (testSomething) (doSomething1) (doSomething2) (doSomething3))
>
> is the same as
>
>(if (testSomething) (doSomething1) . ((doSomething2) (doSomething3)))
>
>
> If 'if' were specified as in the second case (if 'any1 any2 prg), then we
> would
> need to call it as
>
>(if (testSomething) (doSomething1) ((doSomething2) (doSomething3)))
>
> to match the spec (if 'any1 any2 prg) and get the same bindings.
>
>
but this also means the only way to indicate several executable expressions
in the "then-clause" is to surround them between parens, i.e.  (if (= 2 2)
((print "equal") (print "2")) (print "not equal") (print "not 2"))   I
appreciate here an absence of symmetry, you must pack all exe expressions
in a list for "then-clause" but you can't do it for "else-clause"  [in fact
I think it will fail if you do that in a "then-clause" like (if T 1 ((print
"ups") (print "error"))) ]

why not to define and describe function if in a symmetrical way as   (if
'any prg1 prg2)  even when not obeying parens economy?   (sure there is a
good reason to do it that way simply I'm not able to see)

this way you always write prgs inside a list whatever being in then-clause
or an else-clause   i.e.  (if (> a b) ((print "a greater")) ((print "b
greater or equal")))


>
> > > (if T 3 4)   #
> invalid because 4 is a number not a prg (a list)
>
> Yes, but the prg is (4), not 4.
>

I guess you say that because using the "stack" simil you used in previous
email, when you pop first item it remais (T 3 4) when you pop again it
remains (3 4) and with next pop which remains is (4)

I think my confusion is due to the lack of one more pop to get 4 rather
than (4) , if the answer is "because prg indicates its a list, if you want
to indicate a number you should use num instead" then my confusion is like
this:

- two functions f described this way:

   (f num . lst)
   (f num1 num2)

then the list (f 1 2) is a valid call for both functions, the first f will
bind first parameter to numer 1 and second parameter to list (2) (all
remaining parameters as a list) while the second f will bind 1 to num1 and
2 to num2 (descarding empty list NIL). My confusion here is picolisp must
do two pops to bind parameters for a first f function call but three pops
to bind parameters for a second f function call. How discriminate picolisp
between each cases? I suppose the answer is function definition:

first f defined as (de f (X . Rest) (...) )
second f defined as (de f (X Y) (...) )

is it ok?


thanks a lot and forgive my insistence ;-)


Re: a bunch of questions about syntax

2017-01-27 Thread Alexander Burger
On Sat, Jan 28, 2017 at 02:35:09AM +0100, pd wrote:
> sorry, I accidentally sent an incomplete message, here's the complete one
> ...
> >>
> >> BTW, I thought again about the terminology of "list" versus "cons pairs"
> >> and
> >> plain "cells". "list" is a rather unprecise term, I feel it is not
> >> limited to "a
> >> chain of cells with NIL at the end". I use "list" for any sequence of
> >> cells (as
> >> opposed to other structures like "tree", "graph" or "set"). These include
> >> also
> >> e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in
> >> fact, no
> >> end at all).
> >>
> > Ok, so from this point of view every cons pair is a list even those with a
> > dotted pair in the tail

No, definitely not. I would not call (3 . 4) a list. Still, as I said, "list" is
a rather unprecise term. Some people use the term "proper list" for a
NIL-terminated list.


> > I mean, with a NIL ending list you have an empty list condition (NIL) but
> > how do you know a non-NIL ending list is empty? and since most functions

No. Only the atom 'NIL' is the empty list.


> > condition to finish processing the list I think it would be interesting to
> > discriminate between those two kinds of lists.

I think it does not matter. At least it is not very important. Every function in
Lisp is free to treat its arguments as it likes.

The PicoLisp interpreter doesn't care very much. Most list-processing functions
do not check for NIL at the end, but whether the item is atomic or not

   In C:
  while (isCell(cdr(x = cdr(x

   In Asm:
 ld X (X CDR)  # Args
 atom (X CDR)  # more than one left?
  while z  # Yes


> > what about these two? are they equivalent?
> >
> > (f  num   lst) -> num
> > (g num . lst) -> num

No. 'f' takes two argument (supposed to evaluate to a number and a list), while
'g' takes an unlimited number of arguments (the first supposed to be a number
after evaluation, the rest unspecified).


> > of course it's the function body which determines the "type" of
> > parameters, if the body applies a parameter to a function expecting a
> > number, that parameter's type must be a number and not a symbol or list or
> > the function call in the body will fail, but you use a notation for

Right.

> > describing functions just to help users know what kind of parameter you
> > must provide, that's the reason to use that list of meaningful words, type
> > is not enforced (not possible) but suggested to user using the function,
> > right?

Exactly.

> > From this point of view my question is about the difference of using or
> > not using dot when describing a function, for example, take the if
> > description:
> >
> > (if 'any1 any2 . prg) -> any
> >
> > Would the description below describe the same function?
> >
> > (if 'any1 any2 prg) -> any

A typical call of 'if' could be

   (if (testSomething) (doSomething1) (doSomething2) (doSomething3))

where

   any1 is the result of evaluating (testSomething)
   any2 is (doSomething1)
   prg is ((doSomething2) (doSomething3))

Perhaps it helps understanding if we remember that

   (if (testSomething) (doSomething1) (doSomething2) (doSomething3))

is the same as

   (if (testSomething) (doSomething1) . ((doSomething2) (doSomething3)))


If 'if' were specified as in the second case (if 'any1 any2 prg), then we would
need to call it as

   (if (testSomething) (doSomething1) ((doSomething2) (doSomething3)))

to match the spec (if 'any1 any2 prg) and get the same bindings.


> > (if T 3 (print "no")) # valid
> > (if (< 2 2) 'x (print "yeah"))# valid
> > (if T 3 4)# invalid
> > because 4 is a number not a prg (a list)

Yes, but the prg is (4), not 4.


> > (if NIL (print "then") (print "else") (print "finally"))  # a doubt here,
> >
># I
> think it's invalid because two executable expressions are two lists not one
> prg (one list of executable expressions)

No, it is perfectly valid.

   (print "then") is the "then" part, an 'exe'
   ((print "else") (print "finally")) is the "else" part, a 'prg'


> (if (really?) (print (car *Glist)) NIL)   # invalid because you cannot use
> a NIL value as "else" return, you need to supply a executable expressions

No, perfectly valid. The 'prg' is (NIL).

Remember how a 'prg' is executed: Each expressions is evaluated, one after the
other, and the result of the last one is the result of the whole 'prg'. The last
expression evaluated here is NIL, so the result is NIL.


> (if (really?) (print (car *Glist)) (NIL)) # so you must rewrite the

This would crash, as the 'prg' is ((NIL)), thus the last expression is (NIL),
and NIL is not a function.


> The primary data types:
> 
>- num - Number
>- sym - Symbol
>- lst - List
>  ...
>- any - Anything: Any data type
> It's not a matter of type endorsement but a kind of typ

Re: a bunch of questions about syntax

2017-01-27 Thread pd
sorry, I accidentally sent an incomplete message, here's the complete one

On Sat, Jan 28, 2017 at 1:51 AM, pd  wrote:

> Thanks again for your explanations Alex, still some comments...
>
> On Fri, Jan 27, 2017 at 8:16 AM, Alexander Burger 
> wrote:
>
>>
>>
>> BTW, I thought again about the terminology of "list" versus "cons pairs"
>> and
>> plain "cells". "list" is a rather unprecise term, I feel it is not
>> limited to "a
>> chain of cells with NIL at the end". I use "list" for any sequence of
>> cells (as
>> opposed to other structures like "tree", "graph" or "set"). These include
>> also
>> e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in
>> fact, no
>> end at all).
>>
>
> Ok, so from this point of view every cons pair is a list even those with a
> dotted pair in the tail
>
> But I think it's interesting to distinguish between two different kind of
> lists, those having a NIL symbol in last cell CDR (let's say ending in NIL
> symbol) and with a non NIL in las cell CDR (those ending in a symbol not
> NIL) just because of almost every function dealing with lists assume they
> belong to NIL-ending kind.
>
> I mean, with a NIL ending list you have an empty list condition (NIL) but
> how do you know a non-NIL ending list is empty? and since most functions
> dealing with lists have a recursive pattern looking for an empty list
> condition to finish processing the list I think it would be interesting to
> discriminate between those two kinds of lists.
>
> For example, let's define f as:
>
> (de f (L) (print (car L)) (if (<> NIL (cdr L)) (f (cdr L
>
> then f is well defined for NIL ending lists but fails with non-NIL ending
> lists
>
>
>
>
>> > but when describing functions ' is a notation mark with a
>> > semantic, what is the semantic of dot notation mark when used in formal
>> > parameters in function description?
>> >
>> > I mean, you have these two notations for functions:
>> >
>> >   -  (dbs+ 'num . lst)
>> >
>> >   -  (delete 'any 'lst) -> lst
>> >
>> > are they applied the same? with the same kind of parameters?
>>
>> The functions behave differently. (dbs+ 'num . lst) means that the the
>> function
>> takes an unlimited number of arguments, where only the first one is
>> evaluated,
>> while (delete 'any 'lst) takes two evaluated arguments.
>
>
> what about these two? are they equivalent?
>
> (f  num   lst) -> num
> (g num . lst) -> num
>
>
>>
>> > evaluate to a number and rest of parameters will be bound to Z, so you
>> call
>> > this function like (dbs+ 4 a b c) ,  what notation will you use to
>> express
>> > you have to pass a list as parameter to a function?  maybe (dbs+ 'lst)
>> ? I
>>
>> These function definitions say nothing about the types of the arguments
>> like
>> number, list etc. This is determined by the behavior of the function's
>> body.
>>
>>
> of course it's the function body which determines the "type" of
> parameters, if the body applies a parameter to a function expecting a
> number, that parameter's type must be a number and not a symbol or list or
> the function call in the body will fail, but you use a notation for
> describing functions just to help users know what kind of parameter you
> must provide, that's the reason to use that list of meaningful words, type
> is not enforced (not possible) but suggested to user using the function,
> right?
>
> so a function described as(f  'num 'num)   informs that function f
> expects two parameters being numbers and since parameters are evaluated
> it's the value what is expected to be numers, so you can call f as (f 1 2)
> or (f a b) or even (f (x y z) 3) provided that values of symbols a and b
> are numbers and the result of x function call (x y z) returns a number but
> sure you cannot call f as (f (1 2)) or (f 'x 4)
>
> From this point of view my question is about the difference of using or
> not using dot when describing a function, for example, take the if
> description:
>
> (if 'any1 any2 . prg) -> any
>
> Would the description below describe the same function?
>
> (if 'any1 any2 prg) -> any
>
> Even more, having into account notation used for describing functions I
> know:
>
> any - Anything: Any data type
> prg - Prog-Body: A list of executable expressions (run)
>
> so from description of function "if" which is "Conditional execution: If
> the condition any1 evaluates to non-NIL, any2 is evaluated and returned.
> Otherwise, prg is executed and the result returned." I undestand the
> "then" clause is any2 which gets evaluated when evaluated any1 is T and
> also it could be any type of value while prg is the "else" clause being
> evaluated only if evaluation of any1 returns NIL and also it is a list of
> executable expressions, from this I understand the following is a list of
> valid and invalid if function calls:
>
> (if T 3 (print "no")) # valid
> (if (< 2 2) 'x (print "yeah"))# valid
> (if T 3 4)  

Re: a bunch of questions about syntax

2017-01-27 Thread pd
Thanks again for your explanations Alex, still some comments...

On Fri, Jan 27, 2017 at 8:16 AM, Alexander Burger 
wrote:

>
>
> BTW, I thought again about the terminology of "list" versus "cons pairs"
> and
> plain "cells". "list" is a rather unprecise term, I feel it is not limited
> to "a
> chain of cells with NIL at the end". I use "list" for any sequence of
> cells (as
> opposed to other structures like "tree", "graph" or "set"). These include
> also
> e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in
> fact, no
> end at all).
>

Ok, so from this point of view every cons pair is a list even those with a
dotted pair in the tail

But I think it's interesting to distinguish between two different kind of
lists, those having a NIL symbol in last cell CDR (let's say ending in NIL
symbol) and with a non NIL in las cell CDR (those ending in a symbol not
NIL) just because of almost every function dealing with lists assume they
belong to NIL-ending kind.

I mean, with a NIL ending list you have an empty list condition (NIL) but
how do you know a non-NIL ending list is empty? and since most functions
dealing with lists have a recursive pattern looking for an empty list
condition to finish processing the list I think it would be interesting to
discriminate between those two kinds of lists.

For example, let's define f as:

(de f (L) (print (car L)) (if (<> NIL (cdr L)) (f (cdr L

then f is well defined for NIL ending lists but fails with non-NIL ending
lists




> > but when describing functions ' is a notation mark with a
> > semantic, what is the semantic of dot notation mark when used in formal
> > parameters in function description?
> >
> > I mean, you have these two notations for functions:
> >
> >   -  (dbs+ 'num . lst)
> >
> >   -  (delete 'any 'lst) -> lst
> >
> > are they applied the same? with the same kind of parameters?
>
> The functions behave differently. (dbs+ 'num . lst) means that the the
> function
> takes an unlimited number of arguments, where only the first one is
> evaluated,
> while (delete 'any 'lst) takes two evaluated arguments.


what about these two? are they equivalent?

(f  num   lst) -> num
(g num . lst) -> num


>
> > evaluate to a number and rest of parameters will be bound to Z, so you
> call
> > this function like (dbs+ 4 a b c) ,  what notation will you use to
> express
> > you have to pass a list as parameter to a function?  maybe (dbs+ 'lst) ?
> I
>
> These function definitions say nothing about the types of the arguments
> like
> number, list etc. This is determined by the behavior of the function's
> body.
>
>
of course it's the function body which determines the "type" of parameters,
if the body applies a parameter to a function expecting a number, that
parameter's type must be a number and not a symbol or list or the function
call in the body will fail, but you use a notation for describing functions
just to help users know what kind of parameter you must provide, that's the
reason to use that list of meaningful words, type is not enforced (not
possible) but suggested to user using the function, right?

so a function described as(f  'num 'num)   informs that function f
expects two parameters being numbers and since parameters are evaluated
it's the value what is expected to be numers, so you can call f as (f 1 2)
or (f a b) or even (f (x y z) 3) provided that values of symbols a and b
are numbers and the result of x function call (x y z) returns a number but
sure you cannot call f as (f (1 2)) or (f 'x 4)

>From this point of view my question is about the difference of using or not
using dot when describing a function, for example, take the if description:

(if 'any1 any2 . prg) -> any

Would the description below describe the same function?

(if 'any1 any2 prg) -> any

Even more, having into account notation used for describing functions I
know:

any - Anything: Any data type
prg - Prog-Body: A list of executable expressions (run)

so from description of function "if" which is "Conditional execution: If
the condition any1 evaluates to non-NIL, any2 is evaluated and returned.
Otherwise, prg is executed and the result returned." I undestand the "then"
clause is any2 which gets evaluated when evaluated any1 is T and also it
could be any type of value while prg is the "else" clause being evaluated
only if evaluation of any1 returns NIL and also it is a list of executable
expressions, from this I understand the following is a list of valid and
invalid if function calls:

(if T 3 (print "no")) # valid
(if (< 2 2) 'x (print "yeah"))# valid
(if T 3 4)# invalid because
4 is a number not a prg (a list)
(if NIL (print "then") (print "else") (print "finally"))  # a doubt here,
I think it's invalid because two executable expressions are two lists not
one prg (one list of executable expressions)



prg - Prog-Body: A list of executable expressio

Re: a bunch of questions about syntax

2017-01-26 Thread Alexander Burger
On Thu, Jan 26, 2017 at 11:35:20PM +0100, pd wrote:
> Alex, thanks a lot for your very clarifier reply (specially the procedural
> way of thinking which makes a lot of sense to me), I'm still confusing in a
> couple of things...

No problem!

BTW, I thought again about the terminology of "list" versus "cons pairs" and
plain "cells". "list" is a rather unprecise term, I feel it is not limited to "a
chain of cells with NIL at the end". I use "list" for any sequence of cells (as
opposed to other structures like "tree", "graph" or "set"). These include also
e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in fact, no
end at all).


> I've read in docs that the ' prefix in a name of formal parameter when
> describing a funcion indicates it's a evaluated parameter  (even when the

Yes

> opposite is clearer to me , using ' to indicate a non-evaluated parameter
> following the quote notation you use when want to preserve something from
> evaluation)

That would also make sense. I think the notation in the docs mirrors *some*
typical call scenarios.


> but when describing functions ' is a notation mark with a
> semantic, what is the semantic of dot notation mark when used in formal
> parameters in function description?
> 
> I mean, you have these two notations for functions:
> 
>   -  (dbs+ 'num . lst)
> 
>   -  (delete 'any 'lst) -> lst
> 
> are they applied the same? with the same kind of parameters?

The functions behave differently. (dbs+ 'num . lst) means that the the function
takes an unlimited number of arguments, where only the first one is evaluated,
while (delete 'any 'lst) takes two evaluated arguments.


> So I suppose the notation (dbs+ 'num . lst) refers to a function defined as
> (de dbs+ X . Z ...) and thus first parameter is binded to X and also must

Yes, (de dbs+ (X . Z) ..) to be precise.

> evaluate to a number and rest of parameters will be bound to Z, so you call
> this function like (dbs+ 4 a b c) ,  what notation will you use to express
> you have to pass a list as parameter to a function?  maybe (dbs+ 'lst) ? I

These function definitions say nothing about the types of the arguments like
number, list etc. This is determined by the behavior of the function's body.

To indicate that an argument is *expected* to be a list, I usually use 'Lst'

   (de foo (Lst)
  ..

> mean a notation to express you *must* call a function using a list like (f
> (a b c)) and not (f a b c)

Note that (f (a b c)) does not mean that a list will be passed, but depends on
the return value of the function 'a'). Same for (f a b c), it depends on the
values of the symbols 'a', 'b', and 'c'.

There is no strict, static notation for the types of arguments to a function.
This is a dynamic issue.


> Also taking about dot, as you said you have to use delimiters to separate
> symbols and thus you must surround dot with spaces (or any other delimiter
> I suppose, probably you can write the weird sentence (a,.,b) as an
> alternative to (a . b) dotted pair), so I suppose dot is kind of operator
> (maybe a read macro as ' ?) anyway I think it would be interesting if dot

It is *similar* to a read macro, as it controls the behavior of the reader. I
would not call it a "macro", because it has no corresponding expanded or
evaluated representation, like:

   'abc -> (quote . abc)
   `(* 3 4) -> 12

Instead, it is Lisp "syntax", on the same level as parentheses etc.


> could act as an operator being associative to the right, so you can write:
> 
> ( a . b . c . d . NIL)
> 
> to be equal to
> 
> (a . (b . (c . (d . NIL
> 
> and also equal to  (a b c d)
> 
> does it have any sense?

It would be possible to change the reader to accept (a . b . c . d . NIL), but
I'm not sure at the moment. Would there be any advantage?

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


Re: a bunch of questions about syntax

2017-01-26 Thread pd
Alex, thanks a lot for your very clarifier reply (specially the procedural
way of thinking which makes a lot of sense to me), I'm still confusing in a
couple of things...


I've read in docs that the ' prefix in a name of formal parameter when
describing a funcion indicates it's a evaluated parameter  (even when the
opposite is clearer to me , using ' to indicate a non-evaluated parameter
following the quote notation you use when want to preserve something from
evaluation) but when describing functions ' is a notation mark with a
semantic, what is the semantic of dot notation mark when used in formal
parameters in function description?

I mean, you have these two notations for functions:

  -  (dbs+ 'num . lst)

  -  (delete 'any 'lst) -> lst

are they applied the same? with the same kind of parameters?

I mean, if I describe the function F as being:

  -  (F 'num lst) -> num

am I saying the same as if I describe it this way?:

  -  (F 'num . lst) -> num


if not, what is the difference?


> and what means the following notation?
> >
> >   -  (dbs . lst)
>
> This notation is meant to represent a function like
>
>(de dbs Lst ..)
>
> so that a call
>
>(dbs a b c d)
>
> binds (a b c d) to 'Lst'.
>
>(dbs a b c d) = (dbs . (a b c d))
>
>

So I suppose the notation (dbs+ 'num . lst) refers to a function defined as
(de dbs+ X . Z ...) and thus first parameter is binded to X and also must
evaluate to a number and rest of parameters will be bound to Z, so you call
this function like (dbs+ 4 a b c) ,  what notation will you use to express
you have to pass a list as parameter to a function?  maybe (dbs+ 'lst) ? I
mean a notation to express you *must* call a function using a list like (f
(a b c)) and not (f a b c)


Also taking about dot, as you said you have to use delimiters to separate
symbols and thus you must surround dot with spaces (or any other delimiter
I suppose, probably you can write the weird sentence (a,.,b) as an
alternative to (a . b) dotted pair), so I suppose dot is kind of operator
(maybe a read macro as ' ?) anyway I think it would be interesting if dot
could act as an operator being associative to the right, so you can write:

( a . b . c . d . NIL)

to be equal to

(a . (b . (c . (d . NIL

and also equal to  (a b c d)

does it have any sense?


Re: a bunch of questions about syntax

2017-01-26 Thread Alexander Burger
Hi Pd,

>- three base data types: Numbers, Symbols and Cons Pairs (Lists),
>...
> suggesting dotted pairs are the same as lists, both are
> indistinguishable so it should be possible to write any list as a dotted
> pair, i. e. (1 2) = (1 . (2 . NIL)) but what is the list for (1 . 2) dotted
> pair?

Lists are a special kind of cons pairs. We call it a list if the last cell has
NIL in its CDR, just like in your example.

So both (1 2) and (1 . 2) are cons pairs. In fact, each cell in a list is a cons
pair), but only (1) or (1 2) is called a list.


> 2- In the same doc talking about function arguments you can read "A lambda
> expression always has a list of executable expressions as its CDR. The CAR,
> however, must be a either a list of symbols, or a single symbol ...

> a)   : (de foo (X Y . Z) # CAR is a list with a dotted-pair
> tail

Right

> According with the parameters rules the first is supposed to bind X to the
> first evaluated parameter, Y to the second and Z to the rest of parameters

Yes

> but here the rule to apply is the first one, car is a list of symbols (X, Y
> and Z the last two in the dotted pair Y.Z) so every symbol must be binded
> to evaluated parameters

No, the 'Z' means that the rest of the symbols is *not* evaluated.


> (foo (1 2 3 4))
> 
> should bind 1 to X, 2 to Y and 3 to Z discarding 4 but the examples says it
> really binds 1 to X, 2 to Y and (3 4) to Z thus effectively merging first

No. It binds X to (1 2 3 4), and both Y and Z to NIL


If you call

   (foo 1 2 3 4)

then it binds X to 1, Y to 2 and Z to (3 4).




> b)  : (de foo (X . @)   # CAR is a dotted-pair with '@'
> 
> This case is similar to the previous but merging first and second rules but
> in this case first rule doesn't apply because as comment remarks CAR is a
> dotted pair not a list


Perhaps it helps to think about this procedurally: While the list of formal
parameters is a cons pair (i.e. not atomic), the next symbol is popped of and
the evaluated parameter bound to it. Then, if the remaining piece is not NIL,
the rest of the list is bound to it unevaluated.

So if the "list" of formal parameters is just Z

   (de foo Z ..)
   (foo 1 2 3 4 5)

then 'Z' is bound to (1 2 3 4 5).

On the other hand, if it is (X Y . Z)

   (de foo (X Y . Z)
   (foo 1 2 3 4 5)

then first X is popped off

   : (setq Lst '(X Y . Z))
   -> (X Y . Z)

   : (pop 'Lst)
   -> X

so 'X' is bound to 1. 'Lst' is now

   : Lst
   -> (Y . Z)

again, we pop

   : (pop 'Lst)
   -> Y

so we bind Y to 2.

But now 'Lst' is

   : Lst
   -> Z

It became atomic! So we are back at the "simple" case above where we had

   (de foo Z ..)

and Z is bound to (3 4 5).
   

The same systematics apply to cases like

   (de foo @ ...)

and

   (de foo (X Y Z . @)

Does this make sense?



> and what means the following notation?
> 
>   -  (dbs . lst)

This notation is meant to represent a function like

   (de dbs Lst ..)

so that a call

   (dbs a b c d)

binds (a b c d) to 'Lst'.

   (dbs a b c d) = (dbs . (a b c d))



> 4- Usually in classical lisp syntax you must use dot surrounded by spaces
> to indicate a dotted pair, I supposed this will be the same in picolisp
> because of fixed point numbers notation so you always shoud use (sym . sym)

Yes. The dot is not a delimiter.

Atoms are delimited by these characters:

   " \t\n\r\\"'(),[]`~{}"


> to write a dotted paid in particular with transient symbols ("hello" .
> "world") but I saw in this lists messages seeming to use the notation

I would not write it this way, but always as ("hello" . "world").

However, ("hello"."world") is correctly read because the double qoutes
are delimiters.

Same with e.g. ("hello"("world")"!")


I hope I could clear up some smoke.

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


a bunch of questions about syntax

2017-01-26 Thread pd
I was reading the picolip documents ref, tutorial and function reference
and I'm afraid I misunderstand some concepts, so I'm asking a bunch of
questions in the hope you can help to achieve a better picolisp
understanding

1- In the ref document it's said talking about types in picolisp:

   - three base data types: Numbers, Symbols and Cons Pairs (Lists),
   - the three scope variations of symbols: Internal, Transient and
   External, and
   - the special symbol NIL.

suggesting dotted pairs are the same as lists, both are
indistinguishable so it should be possible to write any list as a dotted
pair, i. e. (1 2) = (1 . (2 . NIL)) but what is the list for (1 . 2) dotted
pair?


2- In the same doc talking about function arguments you can read "A lambda
expression always has a list of executable expressions as its CDR. The CAR,
however, must be a either a list of symbols, or a single symbol, and it
controls the evaluation of the arguments to the executable function
according to the following rules:
When the CAR is a list of symbols For each of these symbols an argument is
evaluated, then the symbols are bound simultaneously to the results. The
body of the lambda expression is executed, then the VAL's of the symbols
are restored to their original values. This is the most common case, a
fixed number of arguments is passed to the function. Otherwise, when the
CAR is the symbol @ All arguments are evaluated and the results kept
internally in a list. The body of the lambda expression is executed, and
the evaluated arguments can be accessed sequentially with the args
<http://www.software-lab.de/doc/refA.html#args>, next
<http://www.software-lab.de/doc/refN.html#next>, arg
<http://www.software-lab.de/doc/refA.html#arg> and rest
<http://www.software-lab.de/doc/refR.html#rest> functions. This allows to
define functions with a variable number of evaluated arguments. Otherwise,
when the CAR is a single symbol The symbol is bound to the whole
unevaluated argument list. The body of the lambda expression is executed,
then the symbol is restored to its original value. This allows to define
functions with unevaluated arguments. Any kind of interpretation and
evaluation of the argument list can be done inside the expression body."Also
the doc said the rules for parameters may be combined and show several
examples:


a)   : (de foo (X Y . Z) # CAR is a list with a dotted-pair
tail
According with the parameters rules the first is supposed to bind X to the
first evaluated parameter, Y to the second and Z to the rest of parameters
but here the rule to apply is the first one, car is a list of symbols (X, Y
and Z the last two in the dotted pair Y.Z) so every symbol must be binded
to evaluated parameters, thus a funcion call like:

(foo (1 2 3 4))

should bind 1 to X, 2 to Y and 3 to Z discarding 4 but the examples says it
really binds 1 to X, 2 to Y and (3 4) to Z thus effectively merging first
and third rule, the question is why? since the CAR is not a single symbol
but a list and also the dotted-pair tail (Y.Z) is not a single symbol but a
dotted pair

b)  : (de foo (X . @)   # CAR is a dotted-pair with '@'

This case is similar to the previous but merging first and second rules but
in this case first rule doesn't apply because as comment remarks CAR is a
dotted pair not a list


3-  In the function reference I see several times functions described with
dots in parameter lists, I think it's related to question 2 and it is just
using the merging-rules parameters but what's the difference between these
two notations:

  -  (dbs+ 'num . lst)

  -  (delete 'any 'lst) -> lst

and what means the following notation?

  -  (dbs . lst)

4- Usually in classical lisp syntax you must use dot surrounded by spaces
to indicate a dotted pair, I supposed this will be the same in picolisp
because of fixed point numbers notation so you always shoud use (sym . sym)
to write a dotted paid in particular with transient symbols ("hello" .
"world") but I saw in this lists messages seeming to use the notation
("hello"."world") to write a dotted pair, is it allowed? or maybe is
another kind of data type?



thanks for your replies


Re: miniPicoLisp and Emscripten: news, suggestions and questions

2016-12-11 Thread Christophe Gragnic
On Mon, Dec 12, 2016 at 7:35 AM, Alexander Burger  wrote:
>> I can compile with the bnd[99] trick, until some better idea is found.
>
> Oh! Does this mean that you allocate 99 entries on each call? This expoldes 
> the
> stack size :) And still might be too small if you e.g. 'apply' a longer list 
> to
> a function.

Indeed, that's what you explained here:
http://www.mail-archive.com/picolisp@software-lab.de/msg04472.html

> What about using alloca() ?

You already suugested this here (call this "patience"):
http://www.mail-archive.com/picolisp@software-lab.de/msg04465.html
but now I feel more confident in trying to implement it.
llvm has an alloca in its Intermediate Repr:
http://llvm.org/docs/LangRef.html#alloca-instruction
Still not sure if it maps to the C alloca.

>> In the Makefile, could we have
>> 2a) «CC=gcc» at the top of the file, then $(CC) instead of gcc in the
>> rest of the file?
>
> You are right! I will change that.

Thanks.

>> 2b) «%.o : %.c» instead of «.c.o»
>
> I never saw that. Is it portable? And what is it needed for?

It's a way to specify wildcards.
Sorry, I thought that my version was more mainstream.
I nevertheless find it more readable.

I could find some occurences here (please search for "%.o"):
https://www.gnu.org/software/make/manual/make.html
but couldn't find a dedicated section.

>> 3) Questions about tests
>>
>> 3a) About picoLisp64 now, is there a prefered way to test everything ?
>> `pil test/*.l` ? or something similar ?
>
> The entry point is @lib/test.l. See the comments about local and global usage 
> at
> the beginning of that file.

OK.

>> 3b) Would it be nice to have a `test` target in the Makefile ?
>
> I don't see that very useful.

It could at least serve as documentation (see my previous question!).

>> 3c) Are there somewhere tests for miniPicoLisp ?
>
> Unfortunately not ... :)

I'll try to maintain some for 2017.

Thanks.


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


Re: miniPicoLisp and Emscripten: news, suggestions and questions

2016-12-11 Thread Alexander Burger
Hi Christophe,

> I'm back at tweaking miniPicoLisp for it to be compilable by Emscripten.

Cool!


> I can compile with the bnd[99] trick, until some better idea is found.

Oh! Does this mean that you allocate 99 entries on each call? This expoldes the
stack size :) And still might be too small if you e.g. 'apply' a longer list to
a function.

What about using alloca() ?


> In the Makefile, could we have
> 2a) «CC=gcc» at the top of the file, then $(CC) instead of gcc in the
> rest of the file?

You are right! I will change that.


> 2b) «%.o : %.c» instead of «.c.o»

I never saw that. Is it portable? And what is it needed for?


> 3) Questions about tests
> 
> 3a) About picoLisp64 now, is there a prefered way to test everything ?
> `pil test/*.l` ? or something similar ?

The entry point is @lib/test.l. See the comments about local and global usage at
the beginning of that file.


> 3b) Would it be nice to have a `test` target in the Makefile ?

I don't see that very useful.

> 3c) Are there somewhere tests for miniPicoLisp ?

Unfortunately not ... :)

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


miniPicoLisp and Emscripten: news, suggestions and questions

2016-12-11 Thread Christophe Gragnic
Hi,

I'm back at tweaking miniPicoLisp for it to be compilable by Emscripten.
I'm re-reading posts from a discussion we had:
http://www.mail-archive.com/picolisp@software-lab.de/msg04447.html
It's been 2.5 years now! I'm now a bit stronger in C and can
understand some more bits.

So I opened up my old directories and checked the actual miniPicoLisp.tgz.
I'm glad to see that miniPicoLisp still receives updates!


1) News

I can compile with the bnd[99] trick, until some better idea is found.
The real news is that I managed to make it compute 2+2 (woa).

$ cat test.l
(+ 2 2)
(bye)
$ nodejs picolisp.js < test.l
: -> 4
:
$ echo "(+ 2 2)(bye)" | nodejs picolisp.js
:
$ echo "(print (+ 2 2))(bye)" | nodejs picolisp.js
: 4

Now I have to investigate some more for convenient use
in the CLI and in the browser. Any input is welcome.


2) Minor suggestions

In the Makefile, could we have
2a) «CC=gcc» at the top of the file, then $(CC) instead of gcc in the
rest of the file?
2b) «%.o : %.c» instead of «.c.o»


3) Questions about tests

3a) About picoLisp64 now, is there a prefered way to test everything ?
`pil test/*.l` ? or something similar ?
3b) Would it be nice to have a `test` target in the Makefile ?
3c) Are there somewhere tests for miniPicoLisp ?

Thanks again Alex for providing such awesome software,
and thanks to the community for the warm atmosphere and
the discussions.


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


Re: Two questions

2016-05-08 Thread Jeronimo Pellegrini
On Mon, May 09, 2016 at 12:08:42AM +0200, andr...@itship.ch wrote:
> 2. I don't know of anyone running pil on this vocore device or even
> under OpenWRT distro, so you might have to try out yourself. Post your
> experiences with it here and/or on the wiki for other users. :-)

I do run PicoLisp on an OpenWRT router, but I haven't updated the
OpenWRT pil packages in a while. However, it should be relatively easy
to apply the patches to new versions of PicoLisp:

http://aleph0.info/jp/software/lisp-forth-openwrt/

J.

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


RE: Two questions

2016-05-08 Thread andreas
1. sudo apt-get install picolisp; pil -> (version) -> see for yourself

The version in the distribution package repositories are usually (naturally) a 
bit outdated.
To compile your own picolisp version during hand-install you require a usable 
picolisp version already installed (or java runtime as last resort), so you 
want to apt-get install picolisp anyway.

As changes in releases are usually tiny and almost never (just almost, but hey) 
breaking existing functionality/usage, even an a bit older version of picolisp 
is sufficient.
The introduction page of the new website is obviously directed at picolisp 
beginners, so this should be alright.

JUST DO IT dude, you are pondering too much...

2. I don't know of anyone running pil on this vocore device or even under 
OpenWRT distro, so you might have to try out yourself. Post your experiences 
with it here and/or on the wiki for other users. :-)

Picolisp is tiny both in storage size and memory footprint, so it does great on 
these tiny computers and is in fact used for embedded computing by a number of 
people.


- Original Message -
From: Lawrence Bottorff [mailto:borg...@gmail.com]
To: picolisp@software-lab.de
Sent: Sun, 8 May 2016 11:44:48 -0400
Subject: Two questions

1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, and
do an apt-get install picolisp. Good, but is that a nice, recent version --
or would it be better to hand-install?

2. Does picolisp run on this little guy: http://vocore.io/ . . . In
general, what's picolisp's track record on all these tiny computers?

LB




Re: Two questions

2016-05-08 Thread O.Hamann

Hey Lawrence,

if you are new to picolisp and want to get an impression of how it works 
an try some of the examples, I think "sudo apt-get install picolisp" is 
the perfect way to reach "picoLand" and start exploring it's 
beautifulness immediately.


If you then feel the need of the things, that changed since the (3.1.5 
?) release, that your ubuntu offers you, it's rather easy to install 
additional picolisp-releases side by side (no need for su permissions 
for these local userspace installs, as far as I know).


No need to bother long time which would be the best way - just tap sudo 
apt-get install und look around :-)

Decide later, which release to work with.


Answers to the second question might be found in the maillist archive, 
as there were questions concerning special hardware before.


Picolisp offers a number of flavors out-of-the-box (mini-picolisp, 
ersatz, 32bit, 64bit, (?) , pilOS)

which are different in the way of system ressources they need,
the way they are written in (some in C, 64bit in Assembler, ersatz in Java),
and the features the specific flavor offers
(- but I'm just reading that, I do not know anything real about that -)
so that I always get the impression of 'there should be one way to get 
picolisp run on my desired hardware'.


Hopefully there will be a more precise answer from the list concerning 
your question.


Wish you have much fun with picolisp,

O.



On 08.05.2016 17:44, Lawrence Bottorff wrote:
1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, 
and do an apt-get install picolisp. Good, but is that a nice, recent 
version -- or would it be better to hand-install?


2. Does picolisp run on this little guy: http://vocore.io/ . . . In 
general, what's picolisp's track record on all these tiny computers?


LB




Two questions

2016-05-08 Thread Lawrence Bottorff
1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, and
do an apt-get install picolisp. Good, but is that a nice, recent version --
or would it be better to hand-install?

2. Does picolisp run on this little guy: http://vocore.io/ . . . In
general, what's picolisp's track record on all these tiny computers?

LB


Re: Is this the right place for bugs / questions about PilOS?

2016-04-22 Thread Alexander Burger
On Sat, Apr 23, 2016 at 02:55:47AM +0200, Danilo Kordic wrote:
> 0.0 It is alive!  Acer AOD270 (Intel Atom N2600).
>   `` PilOS 15.11.0

So Acer again! I wonder if any other BIOS (in addition to qemu's) will
work.

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


Re: Is this the right place for bugs / questions about PilOS?

2016-04-22 Thread Danilo Kordic
0.0 It is alive!  Acer AOD270 (Intel Atom N2600).
  `` PilOS 15.11.0
 Heap: 1010MiB
 :
   ''

I downloaded pios.tgz a few minutes ago, or so it feels ;) .  Just `dd'ed
x86-64.img.


Re: Is this the right place for bugs / questions about PilOS?

2016-04-16 Thread cat stevens
Robert,

The link <http://qemu.weilnetz.de/w64/2014/qemu-w64-setup-20140715.exe> you
gave is, interestingly, quite helpful. (That's the non-404 version, because
things got moved around, it seems.)
I was ambivalent about using an emulator inside Wine (since I use Linux,
and don't have much access to Windows), but trying to compile the sources
for that version, and all surrounding versions, was met with linker errors
only *after* 99% of the object files were generated.

Compilation issues aside, the Windows exe does in fact run inside Wine and
PilOS does in fact run inside that, so thank you for that. :D

I'll still have to see if I can pick up an old-ish cheap-ish Acer
somewhere, if that's what I gotta do to run a modern Lisp on bare-metal.

~cat

On Fri, Apr 15, 2016 at 8:12 PM, Robert Herman  wrote:

> Cat,
>
> Try an older version of qemu. If it works, you can try newer ones if they
> have features or bugs corrected that may affect you.
>
> I had the same problem, but thanks to Joe Bogner and Alex, I have it
> running. Here's the link to the older qemu that worked:
>
> http://qemu.weilnetz.de/w64/qemu-w64-setup-20140715.exe
>
> I was running it on Win 8 64-bit at the time.
>
>
> Regards,
>
> Rob
>
>
>
> On 16 April 2016 at 02:46, cat stevens  wrote:
>
>> > This is an error from the BIOS (Was this also Qemu?).
>>
>> Yes, that was Qemu. Here's a screenshot <http://imgur.com/5bCRrVF.png>.
>>
>> It comes after the "Loading PilOS" text, and I found the string constant
>> "READ ERROR 00" in the image binary (at 0xBF), so I thought that was
>> PilOS.
>>
>> I also recompiled using the provided source / instructions on the Wiki,
>> and
>> tried booting the resulting "x86_64.bin" in Qemu and bare metal with the
>> same results.
>>
>> > Most of today's BIOSes seem to implement only the absolute minimum,
>> > which is understandable as modern OSes don't call the BIOS so much any
>> > more.
>>
>> My PC's BIOS is the same (un-updated) one it shipped with, but the trouble
>> with BIOSes is that it's unlikely to find two identical confiugurations on
>> any two systems. :)
>>
>> > This is a pity, and I don't know what to recommend. But at least
>> > Qemu I would have expected to work ...
>>
>> I was kinda looking forward to having a Lisp OS on bare metal, but maybe
>> this is why there aren't that many. :P
>> I'm all ears if you've any suggestions, and I'll definitely keep an eye on
>> development.
>>
>> ~ cat
>>
>> On Fri, Apr 15, 2016 at 12:57 PM, Alexander Burger 
>> wrote:
>>
>> > On Fri, Apr 15, 2016 at 12:08:56PM -0400, cat stevens wrote:
>> > > Hi! I am very interested in the idea and look of PilOS; however, I'm
>> > having
>> > > some issues trying to get started with it. Can I ask about those here?
>> >
>> > Sure! :)
>> >
>> >
>> > > First, the command on the Wiki seems to have an issue, which I asked
>> > about
>> > > here
>> > > <
>> >
>> http://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu
>> > >
>> > > -- it seems like it should be:
>> > >
>> > > qemu-system-x86_64 -drive format=raw,file=x86-64.img
>> >
>> > What I used for Qemu was
>> >
>> >$ qemu-system-x86_64  -m 4096  -smp 4  -ctrl-grab  -no-reboot
>> > pilos/x86-64.img
>> >
>> > so it is similar to what you wrote in the above link, and it worked fine
>> > for me.
>> >
>> >
>> >
>> > > Even when I run that (apparently more correct) command, PilOS gives
>> "READ
>> > > ERROR 09" and hangs.
>> >
>> > This is an error from the BIOS (Was this also Qemu?).
>> >
>> >
>> > > I also tried booting my laptop from the raw disk image written to a
>> USB
>>
>
>


Re: Is this the right place for bugs / questions about PilOS?

2016-04-15 Thread Alexander Burger
On Fri, Apr 15, 2016 at 03:46:06PM -0400, cat stevens wrote:
> > This is an error from the BIOS (Was this also Qemu?).
> 
> Yes, that was Qemu. Here's a screenshot .
> 
> It comes after the "Loading PilOS" text, and I found the string constant
> "READ ERROR 00" in the image binary (at 0xBF), so I thought that was PilOS.

Correct. PilOS prints this message after the $0x42 BIOS call (Extended
Read Sectors) returned an error (Carry bit set).


> I was kinda looking forward to having a Lisp OS on bare metal, but maybe
> this is why there aren't that many. :P

Until now we know that it works on

   - Acer TavelMate P-253E (mine)
   - Acer Aspire One 722 (Mattias Sundblad)

Perhaps you can try to find one of these second-hand?

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


Re: Is this the right place for bugs / questions about PilOS?

2016-04-15 Thread Robert Herman
Cat,

Try an older version of qemu. If it works, you can try newer ones if they
have features or bugs corrected that may affect you.

I had the same problem, but thanks to Joe Bogner and Alex, I have it
running. Here's the link to the older qemu that worked:

http://qemu.weilnetz.de/w64/qemu-w64-setup-20140715.exe

I was running it on Win 8 64-bit at the time.


Regards,

Rob



On 16 April 2016 at 02:46, cat stevens  wrote:

> > This is an error from the BIOS (Was this also Qemu?).
>
> Yes, that was Qemu. Here's a screenshot <http://imgur.com/5bCRrVF.png>.
>
> It comes after the "Loading PilOS" text, and I found the string constant
> "READ ERROR 00" in the image binary (at 0xBF), so I thought that was PilOS.
>
> I also recompiled using the provided source / instructions on the Wiki, and
> tried booting the resulting "x86_64.bin" in Qemu and bare metal with the
> same results.
>
> > Most of today's BIOSes seem to implement only the absolute minimum,
> > which is understandable as modern OSes don't call the BIOS so much any
> > more.
>
> My PC's BIOS is the same (un-updated) one it shipped with, but the trouble
> with BIOSes is that it's unlikely to find two identical confiugurations on
> any two systems. :)
>
> > This is a pity, and I don't know what to recommend. But at least
> > Qemu I would have expected to work ...
>
> I was kinda looking forward to having a Lisp OS on bare metal, but maybe
> this is why there aren't that many. :P
> I'm all ears if you've any suggestions, and I'll definitely keep an eye on
> development.
>
> ~ cat
>
> On Fri, Apr 15, 2016 at 12:57 PM, Alexander Burger 
> wrote:
>
> > On Fri, Apr 15, 2016 at 12:08:56PM -0400, cat stevens wrote:
> > > Hi! I am very interested in the idea and look of PilOS; however, I'm
> > having
> > > some issues trying to get started with it. Can I ask about those here?
> >
> > Sure! :)
> >
> >
> > > First, the command on the Wiki seems to have an issue, which I asked
> > about
> > > here
> > > <
> >
> http://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu
> > >
> > > -- it seems like it should be:
> > >
> > > qemu-system-x86_64 -drive format=raw,file=x86-64.img
> >
> > What I used for Qemu was
> >
> >$ qemu-system-x86_64  -m 4096  -smp 4  -ctrl-grab  -no-reboot
> > pilos/x86-64.img
> >
> > so it is similar to what you wrote in the above link, and it worked fine
> > for me.
> >
> >
> >
> > > Even when I run that (apparently more correct) command, PilOS gives
> "READ
> > > ERROR 09" and hangs.
> >
> > This is an error from the BIOS (Was this also Qemu?).
> >
> >
> > > I also tried booting my laptop from the raw disk image written to a USB
>


Re: Is this the right place for bugs / questions about PilOS?

2016-04-15 Thread cat stevens
> This is an error from the BIOS (Was this also Qemu?).

Yes, that was Qemu. Here's a screenshot <http://imgur.com/5bCRrVF.png>.

It comes after the "Loading PilOS" text, and I found the string constant
"READ ERROR 00" in the image binary (at 0xBF), so I thought that was PilOS.

I also recompiled using the provided source / instructions on the Wiki, and
tried booting the resulting "x86_64.bin" in Qemu and bare metal with the
same results.

> Most of today's BIOSes seem to implement only the absolute minimum,
> which is understandable as modern OSes don't call the BIOS so much any
> more.

My PC's BIOS is the same (un-updated) one it shipped with, but the trouble
with BIOSes is that it's unlikely to find two identical confiugurations on
any two systems. :)

> This is a pity, and I don't know what to recommend. But at least
> Qemu I would have expected to work ...

I was kinda looking forward to having a Lisp OS on bare metal, but maybe
this is why there aren't that many. :P
I'm all ears if you've any suggestions, and I'll definitely keep an eye on
development.

~ cat

On Fri, Apr 15, 2016 at 12:57 PM, Alexander Burger 
wrote:

> On Fri, Apr 15, 2016 at 12:08:56PM -0400, cat stevens wrote:
> > Hi! I am very interested in the idea and look of PilOS; however, I'm
> having
> > some issues trying to get started with it. Can I ask about those here?
>
> Sure! :)
>
>
> > First, the command on the Wiki seems to have an issue, which I asked
> about
> > here
> > <
> http://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu
> >
> > -- it seems like it should be:
> >
> > qemu-system-x86_64 -drive format=raw,file=x86-64.img
>
> What I used for Qemu was
>
>$ qemu-system-x86_64  -m 4096  -smp 4  -ctrl-grab  -no-reboot
> pilos/x86-64.img
>
> so it is similar to what you wrote in the above link, and it worked fine
> for me.
>
>
>
> > Even when I run that (apparently more correct) command, PilOS gives "READ
> > ERROR 09" and hangs.
>
> This is an error from the BIOS (Was this also Qemu?).
>
>
> > I also tried booting my laptop from the raw disk image written to a USB

Re: Is this the right place for bugs / questions about PilOS?

2016-04-15 Thread Alexander Burger
On Fri, Apr 15, 2016 at 12:08:56PM -0400, cat stevens wrote:
> Hi! I am very interested in the idea and look of PilOS; however, I'm having
> some issues trying to get started with it. Can I ask about those here?

Sure! :)


> First, the command on the Wiki seems to have an issue, which I asked about
> here
> <http://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu>
> -- it seems like it should be:
> 
> qemu-system-x86_64 -drive format=raw,file=x86-64.img

What I used for Qemu was

   $ qemu-system-x86_64  -m 4096  -smp 4  -ctrl-grab  -no-reboot  
pilos/x86-64.img

so it is similar to what you wrote in the above link, and it worked fine
for me.



> Even when I run that (apparently more correct) command, PilOS gives "READ
> ERROR 09" and hangs.

This is an error from the BIOS (Was this also Qemu?).


> I also tried booting my laptop from the raw disk image written to a USB. It
> said "Loading PilOS", then printed "Checking for long support..." and hung,
> not continuing for the time I let it sit at that screen (about 20 minutes).
> 
> My laptop is a Toshiba Satellite from 2012, it's 64-bit, has lots of ram
> and has inbuilt SSE 4.2 support, so I don't think it's my hardware.
> 
> Could anyone offer some pointers here? Thanks!

It seems I was lucky with my Acer Travelmate. All BIOS calls worked as
documented. But from the feedback I received meanwhile I get the
impression that this is rather the exception than the rule.

Most of today's BIOSes seem to implement only the absolute minimum,
which is understandable as modern OSes don't call the BIOS so much any
more.

This is a pity, and I don't know what to recommend. But at least
Qemu I would have expected to work ...

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


Is this the right place for bugs / questions about PilOS?

2016-04-15 Thread cat stevens
Hi! I am very interested in the idea and look of PilOS; however, I'm having
some issues trying to get started with it. Can I ask about those here?

First, the command on the Wiki seems to have an issue, which I asked about
here
<http://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu>
-- it seems like it should be:

qemu-system-x86_64 -drive format=raw,file=x86-64.img

Even when I run that (apparently more correct) command, PilOS gives "READ
ERROR 09" and hangs.

I also tried booting my laptop from the raw disk image written to a USB. It
said "Loading PilOS", then printed "Checking for long support..." and hung,
not continuing for the time I let it sit at that screen (about 20 minutes).

My laptop is a Toshiba Satellite from 2012, it's 64-bit, has lots of ram
and has inbuilt SSE 4.2 support, so I don't think it's my hardware.

Could anyone offer some pointers here? Thanks!


Re: Questions about EmuLisp

2016-01-03 Thread Alexander Burger
Hi Christophe,

> These are primarily questions for Alex, but I'm interested
> in the answers of other people too.

I'm afraid that I don't have useful answers, but I try ...


> 1) What do you think of EmuLisp?

I like the fact that it is written in JS, but I don't know its
limitations.

> 2) Would you promote it?
> 3) Would you use it on the futur website for the demo REPL?

Personally I prefer server-side application code, as it gives more power
to the application, and also makes development a lot easier. So it is
not an option for me at the moment. On the client I prefer hand-crafted
JS, which doesn't need to be touched during application development.

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


Re: Questions about EmuLisp

2016-01-02 Thread Henrik Sarvell
Hi Christophe.

AFAIK ClojureScript is pretty much feature complete as opposed to Emu,
there's a risk for confusion and perhaps bad PR if an online REPL
based on Emu becomes the de facto way of playing around with PL for
novices, ie "Why can't I do X which the manual seems to imply?!!" or
"This crap sucks, it can't even do Y." when it in fact can do Y.

Some prominent disclaimer should be there, perhaps with information on
what features are not available.

The fact that PL is now apt-get installable makes it trivial to test
out the real thing too.




On Sat, Jan 2, 2016 at 9:40 PM, Christophe Gragnic
 wrote:
> Hi all,
>
> These are primarily questions for Alex, but I'm interested
> in the answers of other people too.
>
> I'm a big fan of PicoLisp even if I only scratched the surface yet,
> since I don't use the server or the DB.
> I know most of the heavy PicoLisp users here rely extensively
> on the server and the DB and wouldn't use Ersatz for real things.
> So bear with me for questions about EmuLisp,
> which is even "weaker" that Ersatz!
>
> 1) What do you think of EmuLisp?
> 2) Would you promote it?
> 3) Would you use it on the futur website for the demo REPL?
> 4) I'm beginning a journey to the understandings of
> Clojure/ClojureScript and would love to see something
> like this for PicoLisp. Does this ring a bell for someone?
>
> For your information, there is now a NodeJS module:
> https://www.npmjs.com/package/emulisp
>
>
> chri
>
> --
>
> http://profgra.org/lycee/ (site pro)
> http://delicious.com/profgraorg (liens, favoris)
> https://twitter.com/profgraorg
> http://microalg.info (langage de programmation pédagogique)
> http://expressions.club/ (structure des expressions mathématiques)
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Questions about EmuLisp

2016-01-02 Thread Christophe Gragnic
Hi all,

These are primarily questions for Alex, but I'm interested
in the answers of other people too.

I'm a big fan of PicoLisp even if I only scratched the surface yet,
since I don't use the server or the DB.
I know most of the heavy PicoLisp users here rely extensively
on the server and the DB and wouldn't use Ersatz for real things.
So bear with me for questions about EmuLisp,
which is even "weaker" that Ersatz!

1) What do you think of EmuLisp?
2) Would you promote it?
3) Would you use it on the futur website for the demo REPL?
4) I'm beginning a journey to the understandings of
Clojure/ClojureScript and would love to see something
like this for PicoLisp. Does this ring a bell for someone?

For your information, there is now a NodeJS module:
https://www.npmjs.com/package/emulisp


chri

-- 

http://profgra.org/lycee/ (site pro)
http://delicious.com/profgraorg (liens, favoris)
https://twitter.com/profgraorg
http://microalg.info (langage de programmation pédagogique)
http://expressions.club/ (structure des expressions mathématiques)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


RE: questions about the gui

2015-11-21 Thread Denis Fourt
Hi,

Joh-Tob, thanks, of course you are right, it is the job of the OS to prevent 
such conflicts, how could I have forgotten that!!! And thanks for pointing the 
c source file.

Alex, thanks for the explanations, as I had not understood that picolisp 
behaved like a web server without the calling app. (app) is an elegant solution 
to the stateless browser problem.

Denis


> From: a...@software-lab.de
> To: picolisp@software-lab.de
> Subject: Re: questions about the gui
> Date: Sat, 21 Nov 2015 12:55:23 +0100
>
> Hi Denis,
>
> in addition to what Joh-Tob said, let me correct some issues about
> 'app'.
>
>> b) I understand that calling the (app) function allows multiple users to 
>> access
>> an application at the same time, which makes web apps and collaborative 
>> software
>> possible
>
> What (app) really does is establishing a "session".
>
> When a client (browser) connects to the server, the server forks a child
> process which sends a response to the request. This is typically a GET
> request, and the child sends a HTML page to the client. At the same
> time, the server parent process continues to listen for further
> requests.
>
> Now, when (app) is NOT called in the child while it generates its
> response (i.e. it sends a static page), then the child process
> terminates.
>
> If, however, (app) is called, the child does not terminate. It allocates
> a new port to listen for further requests from that client, allows
> login, keeps the session's state, and so on.
>
> So multi-user access to the application is also possible without (app),
> but each request will be answered in a fire-and-forget style.
>
>
>> a process listening on different port is created for each user isn't it?
>
> right, this is what is happening.
>
>
>> So how do you avoid conflict when running independent applications?
>
> To have more than one application running on a single machine, you start
> several server parent processes. Each of them will be independently
> listening on its own port. We use 'httpGate' as a port proxy, so that
> from the browser's view the port is always 80 (HTTP) or 443 (HTTPS), but
> is relayed on the server to the right port (and thus server process).
>
>
>> In case of single user desktop apps, not calling (app) and reserving a port
>> seems sufficient. But in case of several users?
>
> So, as you see, (app) has nothing to do with single- or multi-user.
> Also, a single application will need (app) to allow sessions, and this
> in turn has nothing to do with how many users access this application.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
  PԔ � &j)mX�����zV�u�.n7�

Re: questions about the gui

2015-11-21 Thread Alexander Burger
Hi Denis,

in addition to what Joh-Tob said, let me correct some issues about
'app'.

> b) I understand that calling the (app) function allows multiple users to 
> access
> an application at the same time, which makes web apps and collaborative 
> software
> possible

What (app) really does is establishing a "session".

When a client (browser) connects to the server, the server forks a child
process which sends a response to the request. This is typically a GET
request, and the child sends a HTML page to the client. At the same
time, the server parent process continues to listen for further
requests.

Now, when (app) is NOT called in the child while it generates its
response (i.e. it sends a static page), then the child process
terminates.

If, however, (app) is called, the child does not terminate. It allocates
a new port to listen for further requests from that client, allows
login, keeps the session's state, and so on.

So multi-user access to the application is also possible without (app),
but each request will be answered in a fire-and-forget style.


> a process listening on different port is created for each user isn't it?

right, this is what is happening.


> So how do you avoid conflict when running independent applications?

To have more than one application running on a single machine, you start
several server parent processes. Each of them will be independently
listening on its own port. We use 'httpGate' as a port proxy, so that
from the browser's view the port is always 80 (HTTP) or 443 (HTTPS), but
is relayed on the server to the right port (and thus server process).


> In case of single user desktop apps, not calling (app) and reserving a port
> seems sufficient. But in case of several users?

So, as you see, (app) has nothing to do with single- or multi-user.
Also, a single application will need (app) to allow sessions, and this
in turn has nothing to do with how many users access this application.

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


Re: questions about the gui

2015-11-21 Thread Joh-Tob Schäg
I assume you fear that a port gets binded to a socket twice.
That can not happen, since unix/linux does not allow two processes to bind
the same process.
(app) calls the pil function (port).
The port function itself is able to find a unused port an binds it. For
more details read (doc 'port)
If you are good with C you might want to look inside net.c and understand
doport.
Picolisp takes care of the ports for you.

2015-11-21 9:36 GMT+01:00 Denis Fourt :

> Yes, this helps, I did not understand that psh was a debugging tool. About
> (app), I still would like to know, if there was a way to run more than one
> application on the same computer and be sure that they would not by
> accident decide to use the same port. I understand that within one app
> there is no problem (as long as there are not too many users), but with two
> or more? Or do my network programming memories need a refresh?
>
> Denis
> 
> > From: johtob...@gmail.com
> > To: picolisp@software-lab.de
> > Subject: Re: questions about the gui
> > Date: Sat, 21 Nov 2015 08:51:43 +0100
> >
> >
> > Hello,
> >
> > It is a local shell that connects to a local webserver.
> > It can be used for webdevelopment, you can expect variables and so on.
> > (app) open a new process with a new port. So each process and each
> > single user linked to it can has a own state. The user can connects to
> > his new port
> > Does it help?
> >
> > Am 21.11.2015 08:28 schrieb "Denis Fourt"
> > mailto:denis.p...@hotmail.com>>:
> > Hello,
> > After reading the gui documentation, I would like some help on the
> > following topics, please :
> > a) I am not sure to understand the purpose and the uses of the psh
> function
>   --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


RE: questions about the gui

2015-11-21 Thread Denis Fourt
Yes, this helps, I did not understand that psh was a debugging tool. About 
(app), I still would like to know, if there was a way to run more than one 
application on the same computer and be sure that they would not by accident 
decide to use the same port. I understand that within one app there is no 
problem (as long as there are not too many users), but with two or more? Or do 
my network programming memories need a refresh? 

Denis

> From: johtob...@gmail.com 
> To: picolisp@software-lab.de 
> Subject: Re: questions about the gui 
> Date: Sat, 21 Nov 2015 08:51:43 +0100 
> 
> 
> Hello, 
> 
> It is a local shell that connects to a local webserver. 
> It can be used for webdevelopment, you can expect variables and so on. 
> (app) open a new process with a new port. So each process and each 
> single user linked to it can has a own state. The user can connects to 
> his new port 
> Does it help? 
> 
> Am 21.11.2015 08:28 schrieb "Denis Fourt" 
> mailto:denis.p...@hotmail.com>>: 
> Hello, 
> After reading the gui documentation, I would like some help on the 
> following topics, please : 
> a) I am not sure to understand the purpose and the uses of the psh function 
  --
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: questions about the gui

2015-11-20 Thread Joh-Tob Schäg
Hello,

It is a local shell that connects to a local webserver.
It can be used for webdevelopment, you can expect variables and so on.
(app) open a new process with a new port. So each process and each single
user linked to it can has a own state. The user can connects to his new
port.
Does it help?
Am 21.11.2015 08:28 schrieb "Denis Fourt" :

> Hello,
> After reading the gui documentation, I would like some help on the
> following topics, please :
> a) I am not sure to understand the purpose and the uses of the psh function


Questions about the gui (2nd try)

2015-11-20 Thread Denis Fourt
Hello,

After reading the gui documentation, I would like some help on the following 
topics, please :

a) I am not sure to understand the purpose and the uses of the psh function

b) I understand that calling the (app) function allows multiple users to access 
an application at the same time, which makes web apps and collaborative 
software possible : a process listening on different port is created for each 
user isn't it? So how do you avoid conflict when running independent 
applications? In case of single user desktop apps, not calling (app) and 
reserving a port seems sufficient. But in case of several users? 

I believe this topic has already been addressed, but my understanding remains 
unclear.

Thanks,

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


questions about the gui

2015-11-20 Thread Denis Fourt
Hello,
After reading the gui documentation, I would like some help on the following 
topics, please :
a) I am not sure to understand the purpose and the uses of the psh function

Re: distributed database questions

2015-09-21 Thread Alexander Burger
Hi Oscar,

> I've been trying make a small database server that can be accessed from
> different machines running different picolisp processes.
> Reading about it on the documentation it seems that its possible to set up
> a distributed database using ext,

That's right.


> but its not really clear to me how the setup would go

A fragmentary example is in the reference for '*Ext'

   http://software-lab.de/doc/refE.html#*Ext
   http://software-lab.de/doc/refE.html#ext

You need to specify an IP-address and an external symbol offset for each
remote machine.

What is the external symbol offset? External symbols reside in the DB in
a number of files, usually specified with 'dbs'. The demo example in
"app/er.l" has 12 files:

   (dbs
  (3 +Role +User +Sal (+User pw))  # 512 Prevalent objects
  (0 +Pos) # A:64 Tiny objects
  (1 +Item +Ord)   # B:128 Small objects
  (2 +CuSu)# C:256 Normal objects
  (2 (+Role nm) (+User nm) (+Sal nm))  # D:256 Small indexes
  (4 (+CuSu nr plz tel mob))   # E:1024 Normal indexes
  (4 (+CuSu nm))   # F:1024
  (4 (+CuSu ort))  # G:1024
  (4 (+Item nr sup pr))# H:1024
  (4 (+Item nm))   # I:1024
  (4 (+Ord nr dat cus))# J:1024
  (4 (+Pos itm)) ) # K:1024

This means that all objects have file numbers between 0 and 11 (@ .. K).
Files above K would give an error if accessed. A symbol like {K1} is
accessible, while {L1} is outside the local range.

Now, with 'ext' you map remote objects into the local symbol space.

Specifying offsets like (20 40 60 80) means that the objects of the
first machine can be accessed locally with an offset of 20, those of the
second with 40, and so on.

For example, the object {B7} on the first remote machine will be visible
locally as {AF7} because (hax "B") -> 2 and (hax "AF") -> 22, i.e. an
offset of 20. You can do

   : (show '{AF7}))

and see the contents of {B7} on the first machine, and

   : (show '{BJ7})

to see the contents of {B7} on the second machine.


This was an explanation the mechanisms, and sounds more complicated than
it actually is. In praxis, you don't care about these file numbers and
object names.

You basically need to do do only this:

1. Decide an offset larger than the length of your 'dbs' list. Above,
   the length was 12, so we took 20. Remember that all your files must
   be between 0 and 65535.
2. Define '*Ext' like in the reference, for your IP-addresses and
   offsets.
3. Start a server 'task' on each remote machine, as in the demo
   "app/main.l" in the 'go' function.
4. Done. Now you can (val '{AF7}) or (get '{AF7} 'foo) to access the
   value and properties of object '{B7} on a remote machine.


> and if it would be possible for the terminal processes to 
> make changes to the database.

Direct changes (like (put!> MyObj 'foo 7)) can be done only to local
objects. Remote objects must be changed with RPC mechanisms, by sending
this expression to a remote machine.


BTW, another example for this mechanism can be seen in "java/lib.l".
Here Java objects in the JVM are treated like a remote database, and
show up as normal external symbols in PicoLisp. See the article at

   http://picolisp.com/wiki/?javacode

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


distributed database questions

2015-09-21 Thread Oscar
Hi all.

I've been trying make a small database server that can be accessed from
different machines running different picolisp processes.
Reading about it on the documentation it seems that its possible to set up
a distributed database using ext, but its not really clear to me how 
the setup would go and if it would be possible for the terminal processes to 
make changes to the database.

Any help on the matter would be greatly appreciated.

-Oscar



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


Re: @lib/scrape.l questions

2015-06-26 Thread Alexander Burger
Hi Luis,

> In the above example, I used `in` and the call to `parseLink` works fine.

OK

> But
> (client "picolisp.com" 80 "wiki/?home"
>(while (from "   (parseLink (till "<"
> 
> does not.  AFAICT, each while cycle returns a list which in my view
> would be used as an argument to `parseLink`, but it doesn't work as I
> expect.  `in` opens an input channel, `client` seems to me to return a
> list.

Hmm, as I said, it depends on what 'parseLink' does. However the lists
of characters (i.e. the chopped URLs) should be passed.

I tried this:

   (client "picolisp.com" 80 "wiki/?home"
  (make
 (while (from " I tried to save the whole html file with a `out`, before the `client`
> ...
> (out "hh.html"
>(client "picolisp.com" 80 "wiki/?home"))

This is not a good idea, because 'client' opens its own 'out' back to
the server. You need it inside of 'client', e.g.

   (client "picolisp.com" 80 "wiki/?home"
  (out NIL (echo)) )

BTW, this is the most basic call to see what 'client' does.


> Also tried to append to a file with each iteration:
> (client "picolisp.com" 80 "wiki/?home"
>(while (from "   (out "+hh.html"
>  (msg (till "<")

Hmm, this is also not a good idea. 'msg' prints to stderr, so nothing
gets printed into "hh.html".

Besides this, the (out "+xxx) is OK, however quite some overhead because
it is re-opened and closed all the time. Better would be

   (client ..
  (out "hh.html"
 (while (from "...
(println (till "<")) ..

This will print the lists to the file.


> Frustation is high right now... :-(

Sorry to hear that! But I think we are getting closer ;)
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


  1   2   >