Re: Reference Manual

2015-10-12 Thread Alexander Burger
Hi Jonathan,

> (if 'any1 any2 . prg) -> any
> ...
> I also don't get the "." between "any2" and "prg" - does that mean
> something?

Yes. As you probably know, the dot is used in "dotted pairs" in Lisp, as
a result of a "cons" operation. In general, a list can be written
recursively as

   (any . lst)

e.g.

   : (1 . (2 3 4))
   -> (1 2 3 4)


A 'prg' is a list of 'exe's (executable expressions). So a call like

   (if (someCondition)
  (doThat)
  (doElse1)
  (doElse2) )

can be dissected into

   any1  (someCondition)
   any2  (doThat)
   prg   ((doElse1) (doElse2))

   : '(if (someCondition) (doThat) . ((doElse1) (doElse2)))
   -> (if (someCondition) (doThat) (doElse1) (doElse2))



> Is there any significance in the difference of "any2" and "prg". I would
> have thought they were both "any" type parameters.

In some sense, yes. 'any' is the most general type, it can be anything,
i.e. a number, a symbol or a list. 'prg', however, is typically a list,
so it better describes what 'if' expects.

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


Re: Reference Manual

2015-10-12 Thread Alexander Burger
Hi Jonathan, (and thanks Erik!)


> in the docs I have with my source which is 3.1.11 I have the definition of 
> "if" as
> 
> (if  'any1  'any2  .  prg)  ->  any
> 
> but on the web reference link (http://software-lab.de/doc/refI.html#if) it's
> 
> (if  'any1  any2  .  prg)  ->  any

Very well observed! In fact, this was changed just recently. Quoting
'any2' was (arguably) wrong. This came up in a discussion in IRC.


'any1' is evaluated the normal, expected way, i.e. just upon function
entry. So this must be "quoted" in the referece.

'any2', however, may be evaluated or not, depending on the outcome of
'any1' (as is also the case for the elements of 'prg'). So I would say
'any2' should not be quoted.

(Note still another convention I'm using here in this mail: Writing
'any' in a *pair* of quotes does not refer to the *single* quote used
for evaluated arguments in the reference, but indicates a markup)

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


RE: Reference Manual

2015-10-12 Thread Jonathan Kelly
Oh, I have more questions, but first I should clarify something I just noticed.

in the docs I have with my source which is 3.1.11 I have the definition of "if" 
as

(if  'any1  'any2  .  prg)  ->  any

but on the web reference link (http://software-lab.de/doc/refI.html#if) it's

(if  'any1  any2  .  prg)  ->  any

note the difference in quoting for any2. Which is correct?

Jonathan.

-Original Message-
From: picolisp@software-lab.de [mailto:picolisp@software-lab.de] On Behalf Of 
Erik Gustafson
Sent: Tuesday, 13 October 2015 11:45 AM
To: picolisp@software-lab.de
Subject: Re: Reference Manual

Hey Jonathan,

Great questions!

What is the significance of "any1" being quoted and "any2" not being quoted?
>

 Quoted arguments, in the context of the Function Reference, mean that the 
argument is evaluated by the function. So (if) evaluates its first argument, 
any1, whereas the second argument, any2, is passed in unevaluated=


Re: Reference Manual

2015-10-12 Thread Erik Gustafson
Hey Jonathan,

Great questions!

What is the significance of "any1" being quoted and "any2" not being quoted?
>

 Quoted arguments, in the context of the Function Reference, mean that the
argument is evaluated by the function. So (if) evaluates its first
argument, any1, whereas the second argument, any2, is passed in unevaluated

Reference Manual

2015-10-12 Thread Jonathan Kelly
Hi,

 

Newbie here. I'm a little puzzled by some features of the Reference
manual. Eg for "if"

 

(if 'any1 any2 . prg) -> any

 

What is the significance of "any1" being quoted and "any2" not being
quoted?

I also don't get the "." between "any2" and "prg" - does that mean
something?

Is there any significance in the difference of "any2" and "prg". I would
have thought they were both "any" type parameters.

 

Thanks

Jonathan. 



Re: Reference Manual diagram conventions

2015-03-26 Thread Alexis


Alexander Burger  writes:

In all these documentations, cells are always displayed in the 
form


  +-+-+ | CAR | CDR | +-+-+

The left half of the cell is the CAR, and the right half the 
CDR. Just as the cell resides in memory. The CAR is at the lower 
address, and the CAR at the higher.


The important point is that the pointer *TO* a PicoLisp item may 
point to different parts of the cell:


Ah, okay, now i understand.


Confusing?


No, i found your explanation succinct and clear - thank you!


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


Re: Reference Manual diagram conventions

2015-03-25 Thread Alexander Burger
Hi Rick,

> I think (I’m speculating, that is) that the confusion was due to the
> unusual (but not incorrect) choice of having key/val pairs stored in symbol
> property lists as
> 
>   +-+-+
>   | VAL | KEY |
>   +-+-+
> 
> where VAL is the the CAR position and KEY in the CDR position. There is not
> right or wrong about this, that’s just how it works. I find this point very
> interesting. I believe it has something to do with streamlining the
> picolisp (C or asm) code regarding properties, but I don’t know for sure.
> Alex?

No, this is in fact a fundamentak design decision. It allows the 'var'
concept to be extended to properties, using the 'prop' and '::'
functions.

If the value VAL of a property cell is in the CAR, all functions which
accept a location (noted as 'var' argument in the reference) can
directly operate on it. The KEY is relatively unimportant, it is
only used internally to locate the cell in the property list.


For example, give the symbol 'A' a property with KEY = 'cnt' and VAL
zero:

   : (put 'A 'cnt 0)
   -> 0

If you get the property cell (the pair VAL / KEY above):

   : (prop 'A 'cnt)
   -> (0 . cnt)

you see that the value is in the CAR and the KEY in the CDR.

Now you can increment this:

   : (inc (prop 'A 'cnt))
   -> 1

Check:
   : (get 'A 'cnt)
   -> 1
   : (prop 'A 'cnt)
   -> (1 . cnt)


Another examples with 'push':

   : (push (prop 'A 'lst) 1)
   -> 1
   : (push (prop 'A 'lst) 2)
   -> 2
   : (push (prop 'A 'lst) 3)
   -> 3
   : (get 'A 'lst)
   -> (3 2 1)
   : (prop 'A 'lst)
   -> ((3 2 1) . lst)

   : (with 'A
  (println (pop (:: lst)) (pop (:: lst)))
  (push (:: lst) 7)
  (: lst) )
   3 2
   -> (7 1)

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


Re: Reference Manual diagram conventions

2015-03-25 Thread Danilo Kordic
AFAIK advantage is:
  varPtr = Val;
​as seen in @src/sym.c doSet:
  val(data(c1)) = data(c2);


Re: Reference Manual diagram conventions

2015-03-25 Thread Rick Hanson
I think (I’m speculating, that is) that the confusion was due to the
unusual (but not incorrect) choice of having key/val pairs stored in symbol
property lists as

  +-+-+
  | VAL | KEY |
  +-+-+

where VAL is the the CAR position and KEY in the CDR position. There is not
right or wrong about this, that’s just how it works. I find this point very
interesting. I believe it has something to do with streamlining the
picolisp (C or asm) code regarding properties, but I don’t know for sure.
Alex?
​


Re: Reference Manual diagram conventions

2015-03-25 Thread Alexander Burger
Hi Alexis,

> The "Symbols" section of the PicoLisp Reference Manual:
> http://software-lab.de/doc/ref.html#symbol
> seems to have the convention:
> 
>+-+-+ | cdr | car | +-+-+
> 
> whereas the "Numbers" and "Lists" sections has the convention:
> 
>+-+-+ | car | cdr | +-+-+
> 
> which, in an English-language left-to-right document, is what i
> would expect.

No, this is not the case. In all these documentations, cells are always
displayed in the form

  +-+-+
  | CAR | CDR |
  +-+-+

The left half of the cell is the CAR, and the right half the CDR. Just
as the cell resides in memory. The CAR is at the lower address, and the
CAR at the higher.


The important point is that the pointer *TO* a PicoLisp item may point
to different parts of the cell:

1. In case of a pair (list cell) it points to the address of the CAR

  Pair
  |
  V
  +-+-+
  | CAR | CDR |
  +-+-+

2. In case of a symbol, it points to address of the CDR part of the
   cell, which holds the value of the symbol:

Symbol
|
V
  +-+-+
  |  |  | VAL |
  +--+--+-+

Note that still the CAR part of that cell is on the left side. It holds a 
pointer
to the symbol's tail. The CDR part of the cell holds VAL, the symbol's value.

3. Finally, a bignum cell is pointed to its "middle"

 Bignum
 |
 V
  +-+-+
  | DIG |  |  |
  +-+--+--+

   That is, it points to an address *inside* the cell, not to its
   starting address.

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


Reference Manual diagram conventions

2015-03-25 Thread Alexis


Hi all,

The "Symbols" section of the PicoLisp Reference Manual:

http://software-lab.de/doc/ref.html#symbol

seems to have the convention:

   +-+-+ | cdr | car | +-+-+

whereas the "Numbers" and "Lists" sections has the convention:

   +-+-+ | car | cdr | +-+-+

which, in an English-language left-to-right document, is what i 
would expect.


Is there a particular reason for the former?


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