Re: Question about get/put REPL vs executing a file

2023-09-23 Thread C K Kashyap
Got it - I'll just use non-transient symbols like 'A instead :)

Thanks Alex!
Kashyap

On Sat, Sep 23, 2023 at 12:02 PM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > kashyap@CPC-ckk-S75640M:~$ cat a.l
> > (de add (N D)
> >(put 'STORE N D) )
> > (add "A" 10)
> > (add "B" 20)
> > (prinl (get 'STORE "A"))
> > (prinl (get 'STORE "B"))
> > kashyap@CPC-ckk-S75640M:~$ pil a.l
> > 10
> > 20
> > : (get 'STORE "A")
> > -> NIL
> > : version
> > -> 274406
> >
> > Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL?
>
> No, because transient symbols like "A" and "B" have a file-local scope
> (just
> like symbols in the 'private' namespace).
>
> Property functions like 'put' and 'get' access the value by the symbol
> itself
> (using pointer equality, '=='), not by the name. So the "A" in
>
>(get 'STORE "A")
>
> in the REPL *after* the file is loaded is another symbol than the "A" in
> the
> file *while* it is loaded.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Question about get/put REPL vs executing a file

2023-09-23 Thread Alexander Burger
Hi Kashyap,

> kashyap@CPC-ckk-S75640M:~$ cat a.l
> (de add (N D)
>(put 'STORE N D) )
> (add "A" 10)
> (add "B" 20)
> (prinl (get 'STORE "A"))
> (prinl (get 'STORE "B"))
> kashyap@CPC-ckk-S75640M:~$ pil a.l
> 10
> 20
> : (get 'STORE "A")
> -> NIL
> : version
> -> 274406
> 
> Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL?

No, because transient symbols like "A" and "B" have a file-local scope (just
like symbols in the 'private' namespace).

Property functions like 'put' and 'get' access the value by the symbol itself
(using pointer equality, '=='), not by the name. So the "A" in

   (get 'STORE "A")

in the REPL *after* the file is loaded is another symbol than the "A" in the
file *while* it is loaded.

☺/ A!ex

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


Question about get/put REPL vs executing a file

2023-09-23 Thread C K Kashyap
Hi Alex et al,
Following illustrates the inconsistent behaviour of get/put between file
and REPL.

kashyap@CPC-ckk-S75640M:~$ cat a.l
(de add (N D)
   (put 'STORE N D) )
(add "A" 10)
(add "B" 20)
(prinl (get 'STORE "A"))
(prinl (get 'STORE "B"))
kashyap@CPC-ckk-S75640M:~$ pil a.l
10
20
: (get 'STORE "A")
-> NIL
: version
-> 274406

Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL?

Regards,
Kashyap


Re: get the 'up value of a variable across a lambda

2021-05-24 Thread polifemo
Ok, I see my mistake. I assumed that let and the rest could create
enclosing environments, when only a function call can.

Another example I made of how to use 'up:

: (de f () (and 1000 (up 1 @) @))
-> f
: (and 10 (f))
-> 10

Thanks for the clarification alex!

On Mon, May 24, 2021 at 12:55 AM Alexander Burger 
wrote:

> On Sun, May 23, 2021 at 08:44:32PM -0500, polifemo wrote:
> > `(let @ 1 (let @ 10 (let @ 20 (up 2 @`
>
> This are two misunderstandings in this example:
>
> 1. It has not a good idea to bind '@' in a 'let' expression. '@' is set
>implicitly by flow- and logic-functions, so a correct usage would be
>
>   (and 1 (or 10 (while 20 (up 2 @
>
>or - more realistically -
>
>   (and (foo) (or (bar) (while (zup) (up 2 @
>
> 2. 'up' does not care about 'let', 'use', 'for' etc. They are ignored. An
> up
>"enclosing environment" always means the enclosing *function*
> environment. So
>all the above 'let's all run in the same environment. The same rule
> applies
>to the environment offsets to 'eval' and 'run'.
>
>
> > returns 1, as I expected, if I enclose the 'up expression inside a
> function
>
> This return value of '1' just happens because the environment setup in
> bindeng
> '@' in 'let' is undefined.
>
>
> Let me try to give an example.
>
>(when 7  # The result of 'when' is what we are interested in
>   (extract
>  '((N)  # Here we are in a function
> (when (num? N)  # 'when' sets '@'
>(+ N @) ) )  # so we add the wrong '@'
>  (1 a 2 b 3)))
>-> (2 4 6)
>
>(when 7
>   (extract
>  '((N)  # in a function
> (when (num? N)
>(+ N (up 1 @)) ) )  # Here we get the '7'
>  (1 a 2 b 3)))
>-> (8 9 10)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: get the 'up value of a variable across a lambda

2021-05-23 Thread Alexander Burger
On Sun, May 23, 2021 at 08:44:32PM -0500, polifemo wrote:
> `(let @ 1 (let @ 10 (let @ 20 (up 2 @`

This are two misunderstandings in this example:

1. It has not a good idea to bind '@' in a 'let' expression. '@' is set
   implicitly by flow- and logic-functions, so a correct usage would be

  (and 1 (or 10 (while 20 (up 2 @

   or - more realistically -

  (and (foo) (or (bar) (while (zup) (up 2 @

2. 'up' does not care about 'let', 'use', 'for' etc. They are ignored. An up
   "enclosing environment" always means the enclosing *function* environment. So
   all the above 'let's all run in the same environment. The same rule applies
   to the environment offsets to 'eval' and 'run'.


> returns 1, as I expected, if I enclose the 'up expression inside a function

This return value of '1' just happens because the environment setup in bindeng
'@' in 'let' is undefined.


Let me try to give an example.

   (when 7  # The result of 'when' is what we are interested in
  (extract
 '((N)  # Here we are in a function
(when (num? N)  # 'when' sets '@'
   (+ N @) ) )  # so we add the wrong '@'
 (1 a 2 b 3)))
   -> (2 4 6)

   (when 7
  (extract
 '((N)  # in a function
(when (num? N)
   (+ N (up 1 @)) ) )  # Here we get the '7'
 (1 a 2 b 3)))
   -> (8 9 10)

☺/ A!ex

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


get the 'up value of a variable across a lambda

2021-05-23 Thread polifemo
while
`(let @ 1 (let @ 10 (let @ 20 (up 2 @`
returns 1, as I expected, if I enclose the 'up expression inside a function
like `(de f (N) (up N @))` then no value of N will yield the value of @ in
an environment higher than the innermost let:
`
: (let @ 1 (let @ 10 (let @ 20 (f 3)))
-> 20
`
how can I access the (@ . 1) value in that higher environment from inside
the function?


Re: Why print statement should determine whether I get an error or

2016-12-10 Thread Christophe Gragnic
On Fri, Dec 9, 2016 at 7:58 AM, Bruno Franco
 wrote:
> P.S.
> I'm still new to picolisp, so don't take any of what I say as gospel. And if
> anyone
> can confirm or expand on what I've said, I'd appreciate it a lot.

I'm not a veteran but let me expose what I once understood.

> I think that, in general, you want to quote a symbol when you want to change
> the value of that symbol when the function is evaluated. I think that not
> every function can do this, and I think it is called "destruction."
> […]
> So, if you wanna change what S is using set, quote it.
> If S is a list and you wanna change its innards, don't quote it.

I think that, although technically probably correct, the purpose of quoting or
not quoting may not be summed up like this.

> Here are some functions that behave different if you quote or not their
> symbol argument:
> inc, dec, push, pop, set, setq

Every function will behave the same, it only changes what you throw at them

Re: Why print statement should determine whether I get an error or

2016-12-08 Thread Bruno Franco
Hey Dean,

I think that, in general, you want to quote a sym argument to a function
when
you want to change the value of that symbol. For example:

: (setq A 1)  # Set the value of A to 1
-> 1
: (inc A)   # Evaluate A, *then* pass the result to inc
-> 2
: A
-> 1
: (inc 'A)   # Pass the symbol A to inc
-> 2
: A
-> 2

In (inc A), first A got evaluated to 1, and that 1 was passed to inc, so it
was
the same as (inc 1).
In (inc 'A), the *symbol* A got passed to inc, and inc recognised this and
changed
what A evaluates to.

Another function where this is clear is in pop. It returns the CAR of a
list and, if
given a symbol, it will return the CAR *and* change the value of the symbol.
Here's an example:

: (setq A (1 2 3 4))
-> (1 2 3 4)
: A
-> (1 2 3 4)
: (pop A) # evaluate A, pass that to pop
-> 1
: A
-> (1 2 3 4)
: (pop 'A)# pass the symbol A to pop
-> 1
: A
-> (2 3 4)

Like with inc in the last example, in (pop A) A is evaluated first, to (1 2
3 4),
so what the interpreter sees is (pop (1 2 3 4)).
In contrast, in (pop 'A) the *symbol* A is passed to pop, so the interpreter
both returns the CAR of A, *and *changed the value of the symbol A.

I think that, in general, you want to quote a symbol when you want to change
the value of that symbol when the function is evaluated. I think that not
every
function can do this, and I think it is called "destruction."

set is another function that works differently if the argument is quoted or
not:

: (setq S NIL)
-> NIL
: S
-> NIL
: (set S 1)
!? (set S 1)
NIL -- Protected symbol
? (set 'S 1)
-> 1
? S
-> 1
?
: (set 'S (1 2 3 4))
-> (1 2 3 4)
: S
-> (1 2 3 4)
: (set S 'a)
-> a
: S
-> (a 2 3 4)

When the symbol argument to set is quoted, the value of the symbol is
changed. When it isn't, set expect the argument to be a cons pair (a list),
and changes the value of the CAR of that cons pair, changing the value of
S in the process.

So, if you wanna change what S is using set, quote it.
If S is a list and you wanna change its innards, don't quote it.

This last is actually the part that I understand the least, so if you feel
confused
don't worry: that's probably because I don't know very well what 'm talking
about.

That is more or less all I know.

Here are some functions that behave different if you quote or not their
symbol
argument:
inc, dec, push, pop, set, setq

I recommend you go out and play with them, and if you have any questions,
you'd do us a huge favor by asking them.

P.S.
I'm still new to picolisp, so don't take any of what I say as gospel. And
if anyone
can confirm or expand on what I've said, I'd appreciate it a lot.


On Thu, Dec 8, 2016 at 3:08 PM, Alexander Burger 
wrote:

> Hi Dean,
>
> > I'm used to sprinkling print statements in my code as a way of tracking
> > down bugs but they seem to be affecting my code more than I was
> expecting.
>
> I recommend to look at 'trace' and 'msg'. They both output to stderr and
> don't
> interfer with the expressions.
>
> 'trace' shows what argumments are passed, and what the functions return.
> See the
> tutorial for examples.
>
> 'msg' prints its argument to stderr *and* returns it, so it does not
> destroy the
> flow. For example:
>
>(if (condition)
>   (doTrue)
>   (doFalse1)
>   (doFalse2) )
>
> Now this would be wrong:
>
>(if (condition)
>   (prinl "true")
>   (doTrue)
>   (doFalse1)
>   (doFalse2) )
>
> But this is all right:
>
>(if (msg (condition) " condition")
>   (msg (doTrue) " true")
>   (msm (doFalse1) " false")
>   (doFalse2) )
>
> Even easier is not to modify the source at all, and do instead, before
> starting
> the program
>
>(mapc trace '(condition doTrue doFalse1))
>
> And/or use 'debug' to single-trace your program. Again see the tutorial.
>
>
> > I've also realised I'm never quite sure when and when I shouldn't
> precede a
> > symbol with a quote e.g. as a function argument in a (debug 'Symbol)
> > statement and wonder if there are some very simple rules of thumb.
>
> It is noted in the reference. If an argument is noted as eg. 'any it means
> that
> the argument is *evaluated* (not necessarily that you actually need to
> write a
> quote).
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Why print statement should determine whether I get an error or

2016-12-08 Thread Alexander Burger
Hi Dean,

> I'm used to sprinkling print statements in my code as a way of tracking
> down bugs but they seem to be affecting my code more than I was expecting.

I recommend to look at 'trace' and 'msg'. They both output to stderr and don't
interfer with the expressions.

'trace' shows what argumments are passed, and what the functions return. See the
tutorial for examples.

'msg' prints its argument to stderr *and* returns it, so it does not destroy the
flow. For example:

   (if (condition)
  (doTrue)
  (doFalse1)
  (doFalse2) )

Now this would be wrong:

   (if (condition)
  (prinl "true")
  (doTrue)
  (doFalse1)
  (doFalse2) )

But this is all right:

   (if (msg (condition) " condition")
  (msg (doTrue) " true")
  (msm (doFalse1) " false")
  (doFalse2) )

Even easier is not to modify the source at all, and do instead, before starting
the program

   (mapc trace '(condition doTrue doFalse1))

And/or use 'debug' to single-trace your program. Again see the tutorial.


> I've also realised I'm never quite sure when and when I shouldn't precede a
> symbol with a quote e.g. as a function argument in a (debug 'Symbol)
> statement and wonder if there are some very simple rules of thumb.

It is noted in the reference. If an argument is noted as eg. 'any it means that
the argument is *evaluated* (not necessarily that you actually need to write a
quote).

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


Why print statement should determine whether I get an error or not

2016-12-08 Thread dean
Hi
I'm used to sprinkling print statements in my code as a way of tracking
down bugs but they seem to be affecting my code more than I was expecting.
I've also realised I'm never quite sure when and when I shouldn't precede a
symbol with a quote e.g. as a function argument in a (debug 'Symbol)
statement and wonder if there are some very simple rules of thumb.

Thank you in anticipation and best regards
Dean



(setq Lmnu
'(mAin_mnu-some_fn
  (Settings
 Epic-set_epic
 Yr-set_yr
 Stmnt-set_stmnt
 Pg-set_pg
  )
  (Pdfs
 All-all_pdfs_to_xmls
 Epic-epic_pdfs_to_xmls
  )
  (Vlus_to_single_vlu
  All-all_pdfs_vlus_to_single_vlu
  Epic-epic_pdfs_vlus_to_single_vlu
  )
)
)

(de lmnu_to_mnu_tbl (Lmnu Lkey)
   (for Ele Lmnu
(
if (== (car Ele) NIL)
(
   #(prinl "ok1 Ele is " (str Ele))#


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Thorsten Jolitz
Henrik Sarvell hsarv...@gmail.com
writes:

Hi Henrik,

 why do you want to do this explicitly since it's done for
 you implicitly in all the various type of reference relations you have
 (typically +Link)?

I want to export the objects to a textual representation that might be
edited and then committed again, so I must be able to find out which DB
object is associated to the textual representation. 

 In Macropis I simply use the convention of having a relation called id
 auto increment (by way of http://software-lab.de/doc/refG.html#genKey )
 , that way it doesn't matter which machine something is on, I will
 never have to worry since something like the action /+Page/update/3/
 always updates the object of class +Page with id 3 no matter what the
 {x...} location might look like.

That sounds like a solution I should copy. Just out of curiosity: in a
distributed database, the object ids ({3}, {1-2} ...) are not unique but
might be repeated on different machines?

 However the impetus for this convention was actually the fact that
 functions like db and collect need for instance a +Ref or +Key to be
 able to fetch an object at all, having a +Key called id in all objects
 make things so much easier.

I figured that out too (- db and collect need a +Ref or +Key) and it
makes using a +Key id even more reasonable, I wasn't aware of the id
functions in picolisp, so I thought about my own solution. 

 But anyway, to really answer your question you might want to look
 into: http://software-lab.de/doc/refI.html#id

 And as far as the remote stuff goes with the db id and obj id combo
 AFAIK you have to implement it yourself, you might want to start by
 reading this discussion:
 http://comments.gmane.org/gmane.lisp.picolisp.general/2849

Thanks for the tips, very helpful!


 On Sun, Jan 26, 2014 at 6:56 PM, Thorsten Jolitz
 tjol...@gmail.com wrote:

 Thorsten Jolitz tjol...@gmail.com
 writes:
 
 ,--
 ---
 | Sorry, I sent this post accidentally before I was finished, so I
 have to
 | send it again.
 `--
 ---
 
 
 
 Hi List,
 
 say I want to use the internal Object ID of database object as a
 unique string
 identifier (useful e.g. for export in a textformat), i.e.
 something
 like:
 
 
 ,-
 
 | : (put '{33} 'ID {33})
 
 `-
 
 how do I get the ID from a database object in a program? And is
 there
 some unique identifier for a database too, so that object-id and
 db-id
 could be combined into a globally unique id?
 
 
 
 
 --
 cheers,
 Thorsten
 
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 



-- 
cheers,
Thorsten

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


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Henrik Sarvell

 That sounds like a solution I should copy. Just out of curiosity: in a
 distributed database, the object ids ({3}, {1-2} ...) are not unique but
 might be repeated on different machines?


AFAIK yes. In any case the {x...} locations are changed by the remote
functionality to avoid clashes with local objects, ie a remote object won't
have the same {x...} as it has locally on the remote machine.

This fact could be used in the creation of functions that handle remote
objects more or less transparently, a typical example would the the get
algo, let's say I do (;; Trans user) and Trans is a remote object then the
;; function infers that fact and fetches the user from the remote machine
through the local +Link pointer on that machine.




On Mon, Jan 27, 2014 at 3:16 PM, Thorsten Jolitz tjol...@gmail.com wrote:

 Henrik Sarvell hsarv...@gmail.com
 writes:

 Hi Henrik,

  why do you want to do this explicitly since it's done for
  you implicitly in all the various type of reference relations you have
  (typically +Link)?

 I want to export the objects to a textual representation that might be
 edited and then committed again, so I must be able to find out which DB
 object is associated to the textual representation.

  In Macropis I simply use the convention of having a relation called id
  auto increment (by way of http://software-lab.de/doc/refG.html#genKey )
  , that way it doesn't matter which machine something is on, I will
  never have to worry since something like the action /+Page/update/3/
  always updates the object of class +Page with id 3 no matter what the
  {x...} location might look like.

 That sounds like a solution I should copy. Just out of curiosity: in a
 distributed database, the object ids ({3}, {1-2} ...) are not unique but
 might be repeated on different machines?

  However the impetus for this convention was actually the fact that
  functions like db and collect need for instance a +Ref or +Key to be
  able to fetch an object at all, having a +Key called id in all objects
  make things so much easier.

 I figured that out too (- db and collect need a +Ref or +Key) and it
 makes using a +Key id even more reasonable, I wasn't aware of the id
 functions in picolisp, so I thought about my own solution.

  But anyway, to really answer your question you might want to look
  into: http://software-lab.de/doc/refI.html#id
 
  And as far as the remote stuff goes with the db id and obj id combo
  AFAIK you have to implement it yourself, you might want to start by
  reading this discussion:
  http://comments.gmane.org/gmane.lisp.picolisp.general/2849

 Thanks for the tips, very helpful!


  On Sun, Jan 26, 2014 at 6:56 PM, Thorsten Jolitz
  tjol...@gmail.com wrote:
 
  Thorsten Jolitz tjol...@gmail.com
  writes:
 
  ,--
  ---
  | Sorry, I sent this post accidentally before I was finished, so I
  have to
  | send it again.
  `--
  ---
 
 
 
  Hi List,
 
  say I want to use the internal Object ID of database object as a
  unique string
  identifier (useful e.g. for export in a textformat), i.e.
  something
  like:
 
 
  ,-
 
  | : (put '{33} 'ID {33})
 
  `-
 
  how do I get the ID from a database object in a program? And is
  there
  some unique identifier for a database too, so that object-id and
  db-id
  could be combined into a globally unique id?
 
 
 
 
  --
  cheers,
  Thorsten
 
  --
  UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 
 
 

 --
 cheers,
 Thorsten

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



Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Alexander Burger
Hi Thorsten,

 I want to export the objects to a textual representation that might be
 edited and then committed again, so I must be able to find out which DB
 object is associated to the textual representation. 

Note that in general it is not recommended to access external objects by
their name.

It is true that you can easily write it to a file, simply with 'print',

   (print '{33})

and you can also 'read' it back again.

The problem is that {33} might meanwhile be deleted from the DB, i.e.
the block at offset 33 is returned to the free list, and reading and
accessing this object would result in a runtime error. Or, even worse,
this block may be re-used by some completely different object.

Therefore, as Henrik pointed out, portable access to database objects is
only meaningful via their index keys.


Concerning you intention to export objects to an editable
representation:

There is a 'dump' function exactly for that purpose. It writes arbitrary
Pilog selections to the current output channel.

Taking the salutations from demo 'app' as an example

: (load @lib/too.l)

: (dump (db nm +Sal @@))
   ...
   (obj ((+Sal) nm Herr)
  sex T
  hi Sehr geehrter Herr @1, )
   (obj ((+Sal) nm Herr Dr.)
  sex T
  hi Sehr geehrter Herr Dr. @1, )
   (obj ((+Sal) nm Mr.)
  sex T
  hi Dear Mr. @1, )
   (obj ((+Sal) nm Mrs.)
  sex 0
  hi Dear Mrs. @1, )
   ...

As you see, this is a format which can directly be 'load'ed.


A typical export function for a database looks like

   (de dumpMyDB ()
  (out myDB.l
 (prinl #  (stamp))
 (prinl)
 (prinl # Roles)
 (dump (db nm +Role @@))
 (println '(commit))
 (prinl)
 (prinl # User)
 (dump (db nm +User @@))
 (println '(commit))
 (prinl)
 (prinl # Shops)
 (dump (db id +Shop @@))
 (println '(commit))
 ... )
  (when (dir (tmp))
 (out myDB.tgz
(chdir (tmp)
   (in (append '(tar cfz -) @)
  (echo) ) ) ) ) )

   (de loadMyDB ()
  (when (and (info myDB.tgz) (n0 (car @)))
 (in myDB.tgz
(chdir (tmp)
   (out '(tar xfz -)
  (echo) ) ) ) )
  (load myDB.l) )

'dump' also takes care of related data blobs. In the above example, all
(the 'load'able file and the blobs) are all packed into a single TGZ
file.



 That sounds like a solution I should copy. Just out of curiosity: in a
 distributed database, the object ids ({3}, {1-2} ...) are not unique but
 might be repeated on different machines?

Right. The combination file and offset, which specifies a given
object, may appear on remote machines again. But there is no problem as
long as you use indexes to access the objects.

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


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Alexander Burger
On Mon, Jan 27, 2014 at 09:55:28AM +0100, Alexander Burger wrote:
 'dump' also takes care of related data blobs. In the above example, all
 (the 'load'able file and the blobs) are all packed into a single TGZ
 file.

Oops, slight error! Just for the records: The TGZ file holds only the
blobs, the *.l file is separate.
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Thorsten Jolitz
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 I want to export the objects to a textual representation that might be
 edited and then committed again, so I must be able to find out which DB
 object is associated to the textual representation. 

 Note that in general it is not recommended to access external objects by
 their name.

 It is true that you can easily write it to a file, simply with 'print',

(print '{33})

 and you can also 'read' it back again.

 The problem is that {33} might meanwhile be deleted from the DB, i.e.
 the block at offset 33 is returned to the free list, and reading and
 accessing this object would result in a runtime error. Or, even worse,
 this block may be re-used by some completely different object.

 Therefore, as Henrik pointed out, portable access to database objects is
 only meaningful via their index keys.

Yes, I think what Henrik uses is a good and simple solution.

 Concerning you intention to export objects to an editable
 representation:

 There is a 'dump' function exactly for that purpose. It writes arbitrary
 Pilog selections to the current output channel.

 Taking the salutations from demo 'app' as an example

 : (load @lib/too.l)

 : (dump (db nm +Sal @@))
...
(obj ((+Sal) nm Herr)
   sex T
   hi Sehr geehrter Herr @1, )
(obj ((+Sal) nm Herr Dr.)
   sex T
   hi Sehr geehrter Herr Dr. @1, )
(obj ((+Sal) nm Mr.)
   sex T
   hi Dear Mr. @1, )
(obj ((+Sal) nm Mrs.)
   sex 0
   hi Dear Mrs. @1, )
...

 As you see, this is a format which can directly be 'load'ed.

Another very useful function in PicoLisp! Although in my case I need a
special syntax for the textual representation, and I think its easier to
build that syntax by getting the info from the DB objects than to parse
and modify the dumped DB.

 A typical export function for a database looks like

(de dumpMyDB ()

(de loadMyDB ()

 'dump' also takes care of related data blobs. In the above example, all
 (the 'load'able file and the blobs) are all packed into a single TGZ
 file.

nice

 That sounds like a solution I should copy. Just out of curiosity: in a
 distributed database, the object ids ({3}, {1-2} ...) are not unique but
 might be repeated on different machines?

 Right. The combination file and offset, which specifies a given
 object, may appear on remote machines again. But there is no problem as
 long as you use indexes to access the objects.

Ok, thanks

-- 
cheers,
Thorsten

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


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Thorsten Jolitz

One more doubt:

Without going into the details, assume there is a relation like this

,
| (rel elem-id (+Number))
`

and it is reused:

1. first, it holds an (arbitrary) number that is used during object
   creation to associate it with other objects that are created too in
   the same commit. 

2. once the db-objects are, these id's can be (and are) overwritten to
   omething more meaningfull, I had my own function for this, but now I
   want to use Henriks proposal (integers produced with the id function).

Is step (1) still possible when the relation is defined as

,
| (rel elem-id (+Key +Number))
`

i.e. can I first assign e.g. 37 to it during the object creation, and
then let the 'id' function re-assign e.g. 9 to it when post-processing
the newly created objects?

-- 
cheers,
Thorsten

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


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Alexander Burger
Hi Thorsten,

 ,
 | (rel elem-id (+Number))
 `
 
 and it is reused:
 
 1. first, it holds an (arbitrary) number that is used during object
creation to associate it with other objects that are created too in
the same commit. 
 
 2. once the db-objects are, these id's can be (and are) overwritten to
omething more meaningfull, I had my own function for this, but now I
want to use Henriks proposal (integers produced with the id function).
 
 Is step (1) still possible when the relation is defined as
 
 ,
 | (rel elem-id (+Key +Number))
 `
 
 i.e. can I first assign e.g. 37 to it during the object creation, and
 then let the 'id' function re-assign e.g. 9 to it when post-processing
 the newly created objects?

Yes, sure. The object doesn't care about the meaning of that number.

But (as also Henrik pointed out), this looks very much like a +Link or
+Joint relation, doesn't it? Storing the id of some other object sounds
like a lot of maintenance work, to keep it everything consistent.


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


Re: How to get the Object-ID from a DB-Object?

2014-01-27 Thread Thorsten Jolitz
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 i.e. can I first assign e.g. 37 to it during the object creation, and
 then let the 'id' function re-assign e.g. 9 to it when post-processing
 the newly created objects?

 Yes, sure. The object doesn't care about the meaning of that number.

 But (as also Henrik pointed out), this looks very much like a +Link or
 +Joint relation, doesn't it? Storing the id of some other object sounds
 like a lot of maintenance work, to keep it everything consistent.

No, these numbers are already there and tell me what to link/join, so I
need them for object creation. But once the linked/joined object network
exists, can replace them with something more meaningfull like a unique
elem-ID. 

-- 
cheers,
Thorsten

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


How to get the Object-ID from a DB-Object?

2014-01-26 Thread Thorsten Jolitz

Hi List, 

say I want to use the internal Object ID of database object as a unique string
identifier (useful e.g. for export in a textformat), i.e. something
like:

: (put '{33} 'ID {33})



-- 
cheers,
Thorsten


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


Re: How to get the Object-ID from a DB-Object?

2014-01-26 Thread Thorsten Jolitz
Thorsten Jolitz tjol...@gmail.com
writes:

,-
| Sorry, I sent this post accidentally before I was finished, so I have to
| send it again.
`-


Hi List, 

say I want to use the internal Object ID of database object as a unique string
identifier (useful e.g. for export in a textformat), i.e. something
like:

,-
| : (put '{33} 'ID {33})
`-

how do I get the ID from a database object in a program? And is there
some unique identifier for a database too, so that object-id and db-id
could be combined into a globally unique id?


-- 
cheers,
Thorsten

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


Re: How to get the Object-ID from a DB-Object?

2014-01-26 Thread Henrik Sarvell
Hi Thorsten, why do you want to do this explicitly since it's done for you
implicitly in all the various type of reference relations you have
(typically +Link)?

In Macropis I simply use the convention of having a relation called id auto
increment (by way of http://software-lab.de/doc/refG.html#genKey ) , that
way it doesn't matter which machine something is on, I will never have to
worry since something like the action /+Page/update/3/ always updates the
object of class +Page with id 3 no matter what the {x...} location might
look like.

However the impetus for this convention was actually the fact that
functions like db and collect need for instance a +Ref or +Key to be able
to fetch an object at all, having a +Key called id in all objects make
things so much easier.

But anyway, to really answer your question you might want to look into:
http://software-lab.de/doc/refI.html#id

And as far as the remote stuff goes with the db id and obj id combo AFAIK
you have to implement it yourself, you might want to start by reading this
discussion: http://comments.gmane.org/gmane.lisp.picolisp.general/2849




On Sun, Jan 26, 2014 at 6:56 PM, Thorsten Jolitz tjol...@gmail.com wrote:

 Thorsten Jolitz tjol...@gmail.com
 writes:

 ,-
 | Sorry, I sent this post accidentally before I was finished, so I have to
 | send it again.
 `-


 Hi List,

 say I want to use the internal Object ID of database object as a unique
 string
 identifier (useful e.g. for export in a textformat), i.e. something
 like:

 ,-
 | : (put '{33} 'ID {33})
 `-

 how do I get the ID from a database object in a program? And is there
 some unique identifier for a database too, so that object-id and db-id
 could be combined into a globally unique id?


 --
 cheers,
 Thorsten

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



get function for chart holding list of db objects

2013-09-26 Thread Olaf Hamann
wrote this yesterday night - but was too tired to spell the address right, so here it is again.

--
Hi,

Im getting stuck - any hints are appreciated!

While I finally found out how to connect a +Chart component to a form
so that values are shown (Chart Put Function),
I do not get the clue how to bring changed values back (Chart Get Function).

I think Im in trouble with differentiating between gui components connected
to vars/db objects and gui charts holding db objects and being connected to
gui components.

Ive looked up the code in @app/ord.l etc and I studied on and on the chapters
in the tutorial concerning gui Charts and E/R Field Prefix Classes,
but I was not able to bring that together.

(class +Foo +Entity)
(rel keyA (+Ref +Number) 2)
(rel keyB (+Ref +String))

(dm keyA () (: keyA) )
(dm keyB () (: keyB) )

(de getFooObjs ( Floor Ceil )
(solve ( @F Floor
@C Ceil
(db keyA (@F . @C) @FooObj) )
@FooObj) )

== ({234}{3224]{6342})

(app)
(action
(html 
(form NIL
(gui (+Init +Chart) (getFooObjs 5 100) 3
((FooObj) (list (keyA FooObj) (keyB FooObj) FooObj)) # put function
# no clue about get function
)
(table NIL NIL ((NIL KeyA)(NIL KeyB)(NIL FooObj))
(do 4
(row NIL
(gui 1 (+Lock +NumField) 10)
(gui 2 (+Lock +TextField) 10)
(gui 3 (+Lock +TextField) 8)
## (gui (+DelRowButton) DEL)
) ) ) # table closed
(gui (+UpButton) 1)
(gui (+DnButton) 1)
()
(submit Save)
) #form
) #html
) #action


This works for me, means: i can scroll through the records,
but want to change the values too.

1.) I wonder, if +Chart should be +E/R prefixed to the FooObjs
instead of using getFooObjs.
But how to do that?

2.) How could the Chart Get Function look like?
(sure +Locks will be deleted, when that function works)

3.) Or should the gui components be +E/R prefixed too,
but when is (: home obj) set and what arguments needs (gui +Chart then

4.) I only want to save 1 row at a time (or perhaps delete)
So I think, that submit will be thrown away (as it saves all records)
and a Save-Button will be added to the list of the row elements?

Or do I have to produce one form for each row?



Coding the insert form for one row at a time was done in a minute in the morning,

hack:
(form NIL
(gui a (+NumField) 10)
(gui b (+TextField) 20)
(gui (+Button) Insert Record
( (new! (+Foo)
keyA (val (: home a))
keyB (val (: home b)) ) )
]

but now I think, this is not picolispish (= does not benefit of the pl qualities)
and could also be done with +Chart and E/R Prefix Class?

As Regenaxer told this morning: as soon as there is activity needed, you need a form and then a +Chart .


With kind regards,
and thank you very much in advance,

Olaf






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


Re: get function for chart holding list of db objects

2013-09-26 Thread Alexander Burger
Hi Olaf,

you are quite close, I think.

The 'keyA' relation has a small problem

 (class +Foo +Entity)
 (rel keyA (+Ref +Number) 2)
 (rel keyB (+Ref +String))

'+Ref' takes an optional argument, and '2' should be for '+Number',
so correct would be

   (rel keyA (+Ref +Number) NIL 2)


Then, instead of using Pilog

 (solve '( @F Floor
 @C Ceil
 (db keyA (@F . @C) @FooObj) )
 @FooObj) )

you could also simply (collect 'keyA '+Foo) to get a list of
all objects.

Note, however, that both 'solve' and 'collect' are not so wise if the
database has many '+Foo' objects, because they return _all_ objects and
thus the chart may become huge.

For displaying a possibly infinite number of objects in a chart, it is
better to use '+QueryChart' which displays just the first page of hits
and then lets you scroll down as far as you like. Examples for
+QueryChart can be found in doc/family.l and app/gui.l.


Besides this, your approach

 (gui '(+Init +Chart) (getFooObjs 5 100) 3

is not bad or wrong at all. However, the '+Lock' prefixes in

   (gui 1 '(+Lock +NumField) 10)

make the fields non-editable.

Thus,I would try something like

   (gui '(+Init +Chart) (collect 'keyA '+Foo) 2
  '((This) (list (: keyA) (: keyB)))
  '((L D)
 (when D
(put! D 'keyA (car L))
(put! D 'keyB (cadr L))
D ) ) )
   (table NIL NIL
  '((NIL KeyA) (NIL KeyB))
 (do 8
(row NIL
   (gui 1 '(+NumField) 10)
   (gui 2 '(+TextField) 10) ) ) )
   (scroll 8 T)

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Alexander Burger
Hi Thorsten,

 I have a problem there, I tried
 
 ,
 | home/tj1/bin/picolisp/pil   |
 | home/tj1/bin/picolisp/plmod |
 | home/tj1/bin/picolisp/bin/pil   |
 | home/tj1/bin/picolisp/bin/plmod |
 | home/tj1/bin/picolisp/bin/psh |
 `
 
 but no matter which one  I use, and I always get an error, e.g. 
 
 ,--
 | (prog (load  
 | /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
 | (swank-start /tmp/slime.20688))
 |  
 | Can't exec program:  
 | /home/tj1/bin/picolisp/bin/psh   
 `--
 
 Now I'm a bit confused - which command should I use, and is that related
 to file permissions (they seem alright to me) or something else?

I think this error occurs because the binary 'picolisp' cannot be found.

BTW, 'psh' does not make sense to be executed stand-alone (though this
is not the problem here), because it tries to connect to a running
PicoLisp application server.

But /home/tj1/bin/picolisp/pil or /home/tj1/bin/picolisp/plmod, for
example, should work, if in the directory /home/tj1/bin/picolisp/bin a
binary executable picolisp can be found.



  Is that still valid, or should it rather be 'pil ore 'plmod now? 
  ,---
  | (setq slime-lisp-implementations  
  |   `((picolisp (/usr/bin/picolisp/p) :init slime-init-picolisp)))
  `---
 
  Yes, I think the way picolisp is launched has changed recently, so you
  need the use the correct shell script, likely pil.  Please let me know

Right. 'p' doesn't exist any longer (too easy to conflict).

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Thorsten
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 I have a problem there, I tried
 
 ,
 | home/tj1/bin/picolisp/pil   |
 | home/tj1/bin/picolisp/plmod |
 | home/tj1/bin/picolisp/bin/pil   |
 | home/tj1/bin/picolisp/bin/plmod |
 | home/tj1/bin/picolisp/bin/psh |
 `
 
 but no matter which one  I use, and I always get an error, e.g. 
 
 ,--
 | (prog (load  
 | /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
 | (swank-start /tmp/slime.20688))
 |  
 | Can't exec program:  
 | /home/tj1/bin/picolisp/bin/psh   
 `--
 
 Now I'm a bit confused - which command should I use, and is that related
 to file permissions (they seem alright to me) or something else?

 I think this error occurs because the binary 'picolisp' cannot be found.

strange, I changed $PATH and emacs exec-path:

,---
| ~ $ echo $PATH

| 
/home/tj1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:

| 
/usr/local/scala/bin:/home/tj1/shellscripts:/home/tj1/.cabal/bin:home/tj1/bin/picolisp/bin
`---

,
| ~ $ (print exec-path)  
| (/home/tj1/shellscripts /home/tj1/bin /usr/local/sbin
| /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games
| /usr/local/scala/bin /usr/lib/emacs/23.1/i686-linux-gnu
| /home/tj1/.cabal/bin/ /home/tj1/ /home/tj1/bin/picolisp/bin) 
`
 
and still get the same error message:

,--
| (prog (load  
| /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
| (swank-start /tmp/slime.1757)) 
| Can't exec program:  
| /home/tj1/bin/picolisp/pil   
|  
| Process inferior-lisp exited abnormally with code 1  
`--



 BTW, 'psh' does not make sense to be executed stand-alone (though this
 is not the problem here), because it tries to connect to a running
 PicoLisp application server.

ok, I changed that to 'pil'

 But /home/tj1/bin/picolisp/pil or /home/tj1/bin/picolisp/plmod, for
 example, should work, if in the directory /home/tj1/bin/picolisp/bin a
 binary executable picolisp can be found.

and there is an executable 'picolisp' in /home/tj1/bin/picolisp/bin
(and without slime, with inferior picolisp mode, it works)

,---
| /home/tj1/bin/picoLisp/bin:   
| insgesamt 232 
| drwxr-xr-x  2 tj1 tjx   4096 2011-11-11 15:23 .   
| drwxr-xr-x 19 tj1 tjx   4096 2011-11-15 01:35 ..  
| -rwxr-xr-x  1 tj1 tjx 206636 2011-11-11 15:23 picolisp
| -rwxr-xr-x  1 tj1 tjx107 2010-03-14 16:37 pil 
| -rwxr-xr-x  1 tj1 tjx223 2011-05-30 07:56 plmod   
| -rwxr-xr-x  1 tj1 tjx277 2011-05-06 08:14 psh 
| -rwxr-xr-x  1 tj1 tjx923 2011-05-06 08:45 replica 
| -rwxr-xr-x  1 tj1 tjx   2211 2008-03-09 15:16 watchdog
`---

When using slime, should the inferior buffer a *inferior-lisp* or rather
a *inferior-picolisp* buffer? I guess, the *inferior-lisp* buffer should
be fine ...

Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Alexander Burger
Hi Thorsten,

  I think this error occurs because the binary 'picolisp' cannot be found.
 
 strange, I changed $PATH and emacs exec-path:

As far as the 'picolisp' executable is concerned, the $PATH doesn't
matter at all. All that counts is how it is invoked by the scripts.
About emacs exec-path, however, I can't say anything.


 and still get the same error message:
 
 ,--
 | (prog (load  
 | /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
 | (swank-start /tmp/slime.1757)) 
 | Can't exec program:  
 | /home/tj1/bin/picolisp/pil   
 |  
 | Process inferior-lisp exited abnormally with code 1  
 `--

What happens if you execute it in the shell

   $ /home/tj1/bin/picolisp/pil

I assume that this 'pil' file is

   #!/bin/sh
   exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l $@

so you see that it will try to execute

   /home/tj1/bin/picolisp/bin/picolisp

What does the command

   $ file /home/tj1/bin/picolisp/bin/picolisp

say?


 and there is an executable 'picolisp' in /home/tj1/bin/picolisp/bin
 (and without slime, with inferior picolisp mode, it works)

Ah, ok, I see.

Hmm, then I'm a bit clueless ...

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Thorsten
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 What happens if you execute it in the shell

$ /home/tj1/bin/picolisp/pil

,
| tj1@tj-desktop:~$ /home/tj1/bin/picolisp/pil   
| bash: /home/tj1/bin/picolisp/pil: Datei oder Verzeichnis nicht gefunden
`


 I assume that this 'pil' file is

#!/bin/sh
exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l $@

yes, that it.


 so you see that it will try to execute

/home/tj1/bin/picolisp/bin/picolisp

 What does the command

$ file /home/tj1/bin/picolisp/bin/picolisp

 say?

,--
| tj1@tj-desktop:~$ file /home/tj1/bin/picolisp/bin/picolisp   
| /home/tj1/bin/picolisp/bin/picolisp: ERROR: cannot open  
| `/home/tj1/bin/picolisp/bin/picolisp' (No such file or directory)
`--


 and there is an executable 'picolisp' in /home/tj1/bin/picolisp/bin
 (and without slime, with inferior picolisp mode, it works)

,--
| tj1@tj-desktop:~$ pil
| : (+ 3 5)
| - 8 
| :
`--

very strange. but

,--
| tj1@tj-desktop:~$ /usr/bin/picolisp/pil  
| bash: /usr/bin/picolisp/pil: Ist kein Verzeichnis
| tj1@tj-desktop:~$ /usr/share/picolisp/pil
| :
`--

so thats the solution - I have a local installation, I set the 4 links
to /usr/bin/ and /usr/share/ as described in INSTALL - but apparently
only /usr/share/picolisp is the one that works. 
I have no idea why. 

after changing all calls to 'pil' to '/usr/share/picolisp/pil' and the
call to swank-picolisp to '/usr/share/picolisp/lib/swank-picolisp'
things worked - more or less. 
The connection to slime worked, I get a slime-repl with a pil prompt,
and calculations like (+ 3 4 ) work - but everything is extremely slow,
and after each keystroke I get 'wrong number of arguments' errors ...

but anyway - it works, somehow, finally. 
I should become a software- and usability-tester, I have what it takes
;)

now I'll try to figure out why what is still making problems. 
thanks for your help!

Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Tomas Hlavaty
Hi Thorsten,

 so thats the solution - I have a local installation, I set the 4 links
 to /usr/bin/ and /usr/share/ as described in INSTALL - but apparently
 only /usr/share/picolisp is the one that works.  I have no idea why.

how did you install your local picolisp?  Did you cd src; make?  Can
you find the bin/picolisp executable file after that?

 after changing all calls to 'pil' to '/usr/share/picolisp/pil' and the
 call to swank-picolisp to '/usr/share/picolisp/lib/swank-picolisp'
 things worked - more or less.  The connection to slime worked, I get a
 slime-repl with a pil prompt, and calculations like (+ 3 4 ) work -
 but everything is extremely slow, and after each keystroke I get
 'wrong number of arguments' errors ...

OK.  Now how exactly did you set up your slime?  I think Henrik had a
similar problem because he was using some slime contribs that
swank-picolisp doesn't support.  If you start with those contribs I sent
in the previous email, it should work.

The problem you are seeing is that when you move your cursor, emacs
talks to picolisp to find information about symbols your cursor points
at, e.g. if you write

   pil (+ 1 2)

and then place your cursor above +, slime tries to display information
about +.  I use emacs autodoc and in this case, I see that the symbol
plus is a built-in function, its address and arguments.

It is slow for you because something about this autodoc stuff doesn't
work for you.

 but anyway - it works, somehow, finally.  I should become a software-
 and usability-tester, I have what it takes ;)

Great;-)

You could have a look at the inferior-lisp buffer and you'll see some
messages sent forth and back between emacs and picolisp.  It should give
you an idea what the problem is.

Cheers,

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Tomas Hlavaty
Hi Thorsten,

 When using slime, should the inferior buffer a *inferior-lisp* or
 rather a *inferior-picolisp* buffer? I guess, the *inferior-lisp*
 buffer should be fine ...

It is *inferior-lisp* and the repl is called *slime-repl picolisp*.
They are numbered if you are connecting to multiple servers.

Cheers,

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Thorsten
Tomas Hlavaty t...@logand.com writes:

Hi Tomas,

 swank-picolisp and copied your configuration except the picolisp command 

 ,---
 | usr/bin/picolisp/p
 `---

 I have a problem there, I tried

 ,
 | home/tj1/bin/picolisp/pil   |
 | home/tj1/bin/picolisp/plmod |
 | home/tj1/bin/picolisp/bin/pil   |
 | home/tj1/bin/picolisp/bin/plmod |
 | home/tj1/bin/picolisp/bin/psh |
 `

 isn't there a slash missing to indicate absolute pathname?

this now works with the pil command, although the behaviour is still a
bit strange. 

 but no matter which one  I use, and I always get an error, e.g. 

 ,--
 | (prog (load  
 | /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
 | (swank-start /tmp/slime.20688))
 |  
 | Can't exec program:  
 | /home/tj1/bin/picolisp/bin/psh   
 `--

 I just tried with the latest picolisp from repository and it works.

 My .emacs is something like:

 (setq slime-lisp-implementations
   `((picolisp (/home/tomas/git/picolisp/pil +) :init 
 slime-init-picolisp)))

 (defun slime-init-picolisp (file _)
   (setq slime-protocol-version 'ignore)
   (format %S\n
   `(prog (load ,(expand-file-name
  /home/tomas/git/swank-picolisp/swank-picolisp.l))
  (swank-start ,file

 (add-to-list 'load-path ~/git/picolisp/lib/el/)
 (require 'picolisp)
 (add-to-list 'auto-mode-alist '(\\.l\\' . picolisp-mode))

 (add-hook 'picolisp-mode-hook (lambda () (slime-mode 1)))

 (add-to-list 'load-path ~/lisp/slime/)
 (require 'slime-autoloads)
 (slime-setup '(slime-repl slime-fuzzy slime-fancy slime-asdf))

 (setq slime-net-coding-system 'utf-8-unix)

I spend the afternoon updating to emacs 24, since I read about problems
with emacs 23.1.1 and slime. But nothing changed, its still very slow,
and I get 

,
| error in process filter: Wrong number of arguments: nil, 27
`

constantly when moving in the repl. 
I copied most of your configs too, but to no avail. 


 | (:program /home/tj1/bin/picolisp/bin/psh :program-args nil :buffer

 I think this is wrong program.  See my config above, it should be pil.
 
yes I changed that. 

Thank a lot for your help, I'm kind of exhausted now after installing
slime and installing emacs 24 the whole day - can't think straight ahead
anymore. Have to get used to the new emacs, and then figure out whats
wrong with my slime installation.

The new gnus is incredibly colorfull - I hope you don't see my text in
orange and yellow like I do. 

Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-15 Thread Thorsten
Tomas Hlavaty t...@logand.com writes:


 Hi Tomas,

 When using slime, should the inferior buffer a *inferior-lisp* or
 rather a *inferior-picolisp* buffer? I guess, the *inferior-lisp*
 buffer should be fine ...

 It is *inferior-lisp* and the repl is called *slime-repl picolisp*.
 They are numbered if you are connecting to multiple servers.

That looks good then. 
Thanks

Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Thorsten
Henrik Sarvell hsarv...@gmail.com
writes:

Hi Henrik,

 Does it matter if you can see the definition instead of simply jumping
 to it?

not really.

 Because with the help of CTags I can jump to any defined function or
 method in a .l file.

I tried it once to set up TAG files, but I didn't really succeed. I think
I have to read a bit more in the Emacs manual and then try your tutorial
again. TAGS seem to be really usefull, not only for Picolisp, but
everywhere in Emacs.  

 With jump to documentation you basically get this functionality for
 the built in functions.

I really like this, since I'm still in a phase where I basically have to
look up (almost) every Picolisp function I use, and that was a bit
tedious using the web interface.

 On Sat, Nov 12, 2011 at 2:44 AM, Thorsten
 quintf...@googlemail.com wrote:

 Tomas Hlavaty t...@logand.com writes:

 Hi Tomas,

 I remember that Alex recently mentioned a method how to get the
 signature of any function or method definition loaded in the system.
 Unfortunately, I could not find the related post again.

 Any hints where I have to look  would be appreciated.

 have a look at

    $ git clone http://logand.com/git/swank-picolisp.git

 it does what you are after, even for C/asm functions.

 Thats quite impressive, thanks. I thought slime/swank is only for 
 communication
 with compiled lisps, but well ...

 I can open a picolisp file in slime-mode now, but I can't connect (with
 slime-connect):

 ,---
 | Connecting to Swank on port 4005.. [2 times] open-network-stream: make
 | client process failed: verbindungsaufbau abgelehnt, :name, SLIME
 | Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005
 `---

 I have to check my slime installation ...


 Is that still valid, or should it rather be 'pil ore 'plmod now?
 ,---
 | (setq slime-lisp-implementations
 |       `((picolisp (/usr/bin/picolisp/p) :init slime-init-picolisp)))
 `---

 So, the connection via swank replaces the connection via
 inferior-picolisp/commint - or uses it? And slime-mode replaces
 picolisp-mode, or adds new functionality to it?

 Thats new terrain, I only knew about swank from ENSIME, the emacs scala
 mode, never used slime/swank with a lisp.

 Cheers,
 --
 Thorsten

 --

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

cheers
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Alexander Burger
Hi Henrik, Thorsten,

  Because with the help of CTags I can jump to any defined function or
  method in a .l file.
 
 I tried it once to set up TAG files, but I didn't really succeed. I think
 I have to read a bit more in the Emacs manual and then try your tutorial
 again. TAGS seem to be really usefull, not only for Picolisp, but
 everywhere in Emacs.  

I think that the necessary tags are already there, or can be easily
generated. At least in the latest version of PicoLisp (this was extended
recently a bit).

You can - again - take the 'vi' function as example. It generates a
temporary file ~/.pil/tmp/pid/tags upon startup, so that all
functions defined in the current session are included. The other symbols
(all built-in functions and assembly-level labels, equates etc.) already
come with the distribution in src64/tags).

So, in 'vi', after you edit a function, e.g.

   : (vi 'doc)

you can move the cursor on other symbols, e.g. 'call' in the next line,
and hit Ctrl-']'. There, you may click on 'CDR', and so on.

I think it should be easy to adopt this mechanism to other editors.

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Alexander Burger
On Mon, Nov 14, 2011 at 01:38:56PM +0100, Alexander Burger wrote:
 I think that the necessary tags are already there, or can be easily

I'm assuming that emacs can use the 'vi' tag file format. Am I wrong?
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to get the signature of function and method definitions

2011-11-14 Thread Henrik Sarvell
It's at the end here:
http://www.prodevtips.com/2010/09/29/emacs-color-themes-tags-cedet-ecb-and-other-customizations/

Not much to it, I do things old school ie I put the download in
/opt/picolisp and simply cd there in a shell and do: ctags -e -R
--languages=-JavaScript,-PHP,-C,-Make,-HTML

This will recursively loop through all the folders and generate tags
for everything, for instance all my projects in /opt/picolisp/projects
and the standard library in /opt/picolisp/lib


On Mon, Nov 14, 2011 at 9:18 PM, Thorsten quintf...@googlemail.com wrote:

 Alexander Burger a...@software-lab.de writes:

 Hi Alex,
  On Mon, Nov 14, 2011 at 01:38:56PM +0100, Alexander Burger wrote:
  I think that the necessary tags are already there, or can be easily
 
  I'm assuming that emacs can use the 'vi' tag file format. Am I wrong?

 I must admit I'm a bit overwhelmed by all the new information and
 possibilities I learned about in this thread - will need some time to
 digest all that.

 Since Emacs is such a huge beast, I try to learn it step by step - and
 TAGS was one of the topics I couldn't get my head around easiliy, so I
 just left it for another attempt later on.

 Therefore, I can't really say much about the tag file formats at the
 moment, maybe Henrik can help.

 cheers
 --
 Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Alexander Burger
Hi Henrik,

 Not much to it, I do things old school ie I put the download in
 /opt/picolisp and simply cd there in a shell and do: ctags -e -R
 --languages=-JavaScript,-PHP,-C,-Make,-HTML
 
 This will recursively loop through all the folders and generate tags
 for everything, for instance all my projects in /opt/picolisp/projects
 and the standard library in /opt/picolisp/lib

I see. However, I would see some problems with that:

- 'ctags' doesn't know how to handle the Lisp level functions like '*/',
  and their connection to 'doMulDiv'.

- In the folders may be several files that contain a (de foo (..) ..),
  and 'ctags' doesn't know which are loaded in the current project.

- 'ctags' cannot resolve methods with the same name for different
  classes, and associate each of them with its class.

If you simply let the PicoLisp runtime do it, you have it all in the
right place.

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Henrik Sarvell
1.) Lisp level functions are handled anyway by the jump to documentation script.
2.) It's only a problem when jumping as you then jump to the incorrect
file but since I don't do much global functions anyway this is not a
problem for me, if I jump to http for instance I end up in the right
file.
3.) Correct and could become a potential annoyance when jumping,
unfortunately my autocompletion only locks on to the predefined lisp
functions and all definitions in all open buffers so there it is not a
problem (I was wrong before when I wrote in my article that it would
lock on tags too).

On Tue, Nov 15, 2011 at 12:22 AM, Alexander Burger a...@software-lab.de wrote:
 Hi Henrik,

 Not much to it, I do things old school ie I put the download in
 /opt/picolisp and simply cd there in a shell and do: ctags -e -R
 --languages=-JavaScript,-PHP,-C,-Make,-HTML

 This will recursively loop through all the folders and generate tags
 for everything, for instance all my projects in /opt/picolisp/projects
 and the standard library in /opt/picolisp/lib

 I see. However, I would see some problems with that:

 - 'ctags' doesn't know how to handle the Lisp level functions like '*/',
  and their connection to 'doMulDiv'.

 - In the folders may be several files that contain a (de foo (..) ..),
  and 'ctags' doesn't know which are loaded in the current project.

 - 'ctags' cannot resolve methods with the same name for different
  classes, and associate each of them with its class.

 If you simply let the PicoLisp runtime do it, you have it all in the
 right place.

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

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Thorsten
Alexander Burger a...@software-lab.de writes:


Hi Alex,
 On Mon, Nov 14, 2011 at 01:38:56PM +0100, Alexander Burger wrote:
 I think that the necessary tags are already there, or can be easily

 I'm assuming that emacs can use the 'vi' tag file format. Am I wrong?

I'm afraid not, I used 

,-
| M-. 
| (find-tag tagname optional next-p regexp-p)
`-

on 'while' in a picolisp source-file in @/src64. and got the following
message:

,-
| visit-tags-table-buffer:
| File /home/tj1/bin/picoLisp/src64/tags is not a valid tags table
`-

Is that ctags or etags or something else what 'vi' uses? 


,---
| *emacs-tags* *emacs_tags* *E430*  
| Emacs style tag files are only supported if Vim was compiled with the 
| |+emacs_tags| feature enabled.  Sorry, there is no explanation about Emacs tag
| files here, it is only supported for backwards compatibility :-). 
|   
| Lines in Emacs tags files can be very long.  Vim only deals with lines of up  
| to about 510 bytes.  To see whether lines are ignored set 'verbose' to 5 or   
| higher.   
|   
| http://vimdoc.sourceforge.net/htmldoc/tagsrch.html
`---

If 'vi' uses (exuberant) ctags, it seems you could produce an etags TAGS
file for emacs by simply running 'ctags -e'. 


,-
| Despite the wealth of available options, defaults are set so that ctags |
| is most commonly executed without any options (e.g. ctags *, or ctags|
| −R), which will create a tag file in the current directory for all |
| recognized source files. The options described below are provided merely|
| to allow custom tailoring to meet special needs.|
| |
| −e  |
| |
| Enable etags mode, which will create a tag file for use with the Emacs  |
| editor. Alternatively, if ctags is invoked by a name containing the |
| string etags (either by renaming, or creating a link to, the  |
| executable), etags mode will be enabled. This option must appear before |
| the first file name.|
| http://ctags.sourceforge.net/ctags.html#HOW%20TO%20USE%20WITH%20GNU%20EMACS |
| |
`-

cheers
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Alexander Burger
Hi Thorsten,

 ,-
 | visit-tags-table-buffer:
 | File /home/tj1/bin/picoLisp/src64/tags is not a valid tags table
 `-
 
 Is that ctags or etags or something else what 'vi' uses? 

Yes, so this seems indeed to be te case.


 ...
 If 'vi' uses (exuberant) ctags, it seems you could produce an etags TAGS
 file for emacs by simply running 'ctags -e'. 

There must surely be a way.

Then the easiest would probably be (if the intention is anyway to write
an emacs version of 'vi'), to modify this part of 'vi'

  (out (tmp tags)
 (let D (pack (pwd) /)
(for This (sort (all))
   (let? P (path (: *Dbg 1 -1))
  (prinl
 This
 ^I
 (unless (= `(char /) (char P)) D)
 P
 ^I
 (: *Dbg 1 1) ) ) ) ) )

to output an emacs compatible format.

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


Re: How to get the signature of function and method definitions

2011-11-14 Thread Thorsten
Tomas Hlavaty t...@logand.com writes:

Hi Henrik, Hi Tomas,
thanks for your help so far. 

I now have slime and sbcl installed and working, and I downloaded
swank-picolisp and copied your configuration except the picolisp command 

,---
| usr/bin/picolisp/p
`---

I have a problem there, I tried

,
| home/tj1/bin/picolisp/pil   |
| home/tj1/bin/picolisp/plmod |
| home/tj1/bin/picolisp/bin/pil   |
| home/tj1/bin/picolisp/bin/plmod |
| home/tj1/bin/picolisp/bin/psh |
`

but no matter which one  I use, and I always get an error, e.g. 

,--
| (prog (load  
| /home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l)
| (swank-start /tmp/slime.20688))
|  
| Can't exec program:  
| /home/tj1/bin/picolisp/bin/psh   
`--

Now I'm a bit confused - which command should I use, and is that related
to file permissions (they seem alright to me) or something else?
Do you use recent versions of picolisp?


here is the backtrace I get when I try to open a test2.l file:

,-
| Debugger entered--Lisp error: (error Process inferior-lisp not 
| running) process-send-string(#process inferior-lisp (prog (load 
| \/home/tj1/bin/picolisp/lib/swank-picolisp/swank-picolisp.l\) 
| (swank-start \/tmp/slime.20688\))\n) (let ((str ...)) (goto-char 
| (process-mark process)) (insert-before-markers str) (process-send-string
| process str)) (save-current-buffer (set-buffer (process-buffer process))
| (make-local-variable (quote slime-inferior-lisp-args)) (setq
| slime-inferior-lisp-args args) (let (...) (goto-char ...)   
| (insert-before-markers str) (process-send-string process str))) 
| (with-current-buffer (process-buffer process) (make-local-variable  
| (quote slime-inferior-lisp-args)) (setq slime-inferior-lisp-args args)  
| (let (...) (goto-char ...) (insert-before-markers str)  
| (process-send-string process str))) (let* ((--cl-rest-- args)   
| (coding-system ...) (init ...)) (with-current-buffer (process-buffer
| process) (make-local-variable ...) (setq slime-inferior-lisp-args args) 
| (let ... ... ... ...))) (progn (let* (... ... ...) (with-current-buffer 
| ... ... ... ...))) (destructuring-bind (key coding-system init 
| allow-other-keys) args (with-current-buffer (process-buffer process)   
| (make-local-variable ...) (setq slime-inferior-lisp-args args) (let ... 
| ... ... ...))) slime-start-swank-server(#process inferior-lisp
| (:program /home/tj1/bin/picolisp/bin/psh :program-args nil :buffer
| *inferior-lisp* :coding-system iso-latin-1-unix :init 
| slime-init-picolisp :name picolisp :init-function nil :env nil))
| slime-inferior-connect(#process inferior-lisp (:program   
| /home/tj1/bin/picolisp/bin/psh :program-args nil :buffer  
| *inferior-lisp* :coding-system iso-latin-1-unix :init 
| slime-init-picolisp :name picolisp :init-function nil :env nil)) (let   
| ((proc ...)) (slime-inferior-connect proc args) (pop-to-buffer  
| (process-buffer proc))) (let ((args ...)) (slime-check-coding-system
| coding-system) (when (slime-bytecode-stale-p)   
| (slime-urge-bytecode-recompile)) (let (...) (slime-inferior-connect proc
| args) (pop-to-buffer ...))) (catch (quote --cl-block-slime-start--) (let
| (...) (slime-check-coding-system coding-system) (when ... ...) (let ... 
| ... ...))) (cl-block-wrapper (catch (quote --cl-block-slime-start--)
| (let ... ... ... ...))) (block slime-start (let (...)   
| (slime-check-coding-system coding-system) (when ... ...) (let ... ...   
| ...))) (let* ((program ...) (program-args ...) (directory ...)  
| (coding-system ...) (init ...) (name ...) (buffer ...) (init-function   
| ...) (env ...)) (let (...) (while --cl-keys-- ...)) (block slime-start  
| (let ... ... ... ...))) slime-start(:name picolisp :program 
| /home/tj1/bin/picolisp/bin/psh :program-args nil :init
| slime-init-picolisp) apply(slime-start (:name picolisp :program 
| /home/tj1/bin/picolisp/bin/psh :program-args nil :init
| slime-init-picolisp)) slime-start*((:name picolisp :program 
| /home/tj1/bin/picolisp/bin/psh :program-args nil :init
| slime-init-picolisp)) (let ((inferior-lisp-program ...) 
| (slime-net-coding-system ...)) (slime-start* (cond ... ...))) slime

Re: How to get the signature of function and method definitions

2011-11-12 Thread Tomas Hlavaty
Hi Thorsten,

 Thats quite impressive, thanks. I thought slime/swank is only for
 communication with compiled lisps, but well ...

slime/swank is a client/server protocol.  There are backends e.g. for
Common Lisp, Scheme, Clojure, R, Picolisp and probably more.  It is not
difficult to write a new backend, if your interpreter supports the
features you are after.  I find it much better that the traditional
commint stuff. I use slime daily and can't imagine life without it
anymore;-) Definitely the way to go if you don't follow Alex's steps
with xterm and vi.  I haven't implemented the whole protocol yet, but
the subset in swank-picolisp is already usable and very helpful.

 I can open a picolisp file in slime-mode now, but I can't connect
 (with slime-connect):

 ,---
 | Connecting to Swank on port 4005.. [2 times] open-network-stream: make
 | client process failed: verbindungsaufbau abgelehnt, :name, SLIME  
 | Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005  
 `---

 I have to check my slime installation ...

 Is that still valid, or should it rather be 'pil ore 'plmod now? 
 ,---
 | (setq slime-lisp-implementations  
 |   `((picolisp (/usr/bin/picolisp/p) :init slime-init-picolisp)))
 `---

Yes, I think the way picolisp is launched has changed recently, so you
need the use the correct shell script, likely pil.  Please let me know
it it worked for you.  You should get a repl and then type (+ 1 2) and
get the result.  If you move your cursor around, you should see function
arguments in the message buffer and if you do M-. and M-, then you
should be jumping around the sources.

 So, the connection via swank replaces the connection via
 inferior-picolisp/commint - or uses it? And slime-mode replaces
 picolisp-mode, or adds new functionality to it?

Swank is a client/server protocol that doesn't use commint mode, it
talks to the picolisp interpreter via socket.  Slime mode extends
picolisp mode with the ability to talk to the server interpreter(s) via
the swank protocol.

 Thats new terrain, I only knew about swank from ENSIME, the emacs
 scala mode, never used slime/swank with a lisp.

I didn't know Scala worked with slime too.

I recommend reading about slime and watching some videos (look for slime
and Marco Baringer), e.g.

http://www.youtube.com/watch?v=_B_4vhsmRRI
http://bc.tech.coop/blog/050728.html
http://common-lisp.net/project/slime/
https://secure.wikimedia.org/wikipedia/en/wiki/SLIME
http://www.emacswiki.org/emacs/SlimeMode

Cheers,

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


Re: How to get the signature of function and method definitions

2011-11-11 Thread Thorsten
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 Perhaps the output mode (console cooked vs. raw) is not right? Does it
 behave correctly if you start it - without emacs - just from the shell

$ pil +

 in the default way?

picolisp does work from the shell - but not 'doc:

,-
| tj1@tj-desktop:~$ pil + 
| + open: No such file or directory   
| ?   
| : (+ 2 3)   
| - 5
| : (pp 'insert)  
| (de insert (N Lst X)
| (conc (cut (dec N) 'Lst) (cons X) Lst) )
| - insert   
| : (doc 'insert) 
| !? (doc 'insert)
| doc -- Undefined
| ?   
| :   
`-


Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-11 Thread Alexander Burger
Hi Thorsten,

  Perhaps the output mode (console cooked vs. raw) is not right? Does it
  behave correctly if you start it - without emacs - just from the shell
 
 $ pil +
 
  in the default way?
 
 picolisp does work from the shell - but not 'doc:
 
 ,-
 | tj1@tj-desktop:~$ pil + 
 | + open: No such file or directory   

Oops, do you use a rather old version? The '+' as debug flag was
introduced with picoLisp-3.0.6 (before March 2011).


 | !? (doc 'insert)
 | doc -- Undefined

This happens because the '+' was not recognized, and thus the debugger
and related information were not loaded.

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


How to get the signature of function and method definitions

2011-11-10 Thread Thorsten

Hi list, 

I remember that Alex recently mentioned a method how to get the
signature of any function or method definition loaded in the system.
Unfortunately, I could not find the related post again.

Any hints where I have to look  would be appreciated.

cheers
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-10 Thread Henrik Sarvell
I don't know if this is exactly what you want but (all) can be used to
inspect stuff, an example of getting all loaded classes:

(de getClasses ()

  (filter
 '((S)
 (and
(= `(char +) (char S))
(type S)))
 (all)))


On Thu, Nov 10, 2011 at 7:27 PM, Thorsten quintf...@googlemail.com wrote:

 Hi list,

 I remember that Alex recently mentioned a method how to get the
 signature of any function or method definition loaded in the system.
 Unfortunately, I could not find the related post again.

 Any hints where I have to look  would be appreciated.

 cheers
 --
 Thorsten

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

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


Re: How to get the signature of function and method definitions

2011-11-10 Thread Alexander Burger
Hi Thorsten,

 I remember that Alex recently mentioned a method how to get the
 signature of any function or method definition loaded in the system.

I'm not completely sure what you mean with signature in this context.


You can inspect a function by pretty-printing,

   : (pp 'insert)
   (de insert (N Lst X)
  (conc (cut (dec N) 'Lst) (cons X) Lst) )

by looking at it with an editor (sorry, only 'vim' at the moment),

   : (vi 'insert)

or access its reference

   : (doc 'insert)


A signature in the sense of C or Java is perhaps

   : (car insert)
   - (N Lst X)

i.e. the formal parameters of the function.

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


Re: How to get the signature of function and method definitions

2011-11-10 Thread Thorsten
Alexander Burger a...@software-lab.de writes:

Hi Alex,

 I remember that Alex recently mentioned a method how to get the
 signature of any function or method definition loaded in the system.

 I'm not completely sure what you mean with signature in this context.


 You can inspect a function by pretty-printing,

: (pp 'insert)
(de insert (N Lst X)
   (conc (cut (dec N) 'Lst) (cons X) Lst) )

too much output in this case

 by looking at it with an editor (sorry, only 'vim' at the moment),

: (vi 'insert)

that was another question of mine - what would it take to get a

,
| (emacs 'insert)
`

function, and a 

,---
| (edit 'insert)
`---

that opens an emacs window?

 or access its reference

: (doc 'insert)

gives me this output - is that intended for vim too? (sorry for the long
lines). 

: (doc 'insert)
1,02kbloaded-(208730594.32315):(stamp73059432315)-2000-06-1708:58:35(init 
'tree ['any1] ['any2]) - 
lstInitializesastructureforsteppingiterativelythroughadatabasetree.any1andany2mayspecifyarangeofkeys.Ifany2isgreaterthanany1,thetraversalwillbeinoppositedirection.Seealsotree,step,iterandscan.:(init(tree'nr'+Item)35)-(((3.5)((3NIL.{3-3})(4NIL.{3-4})(5NIL.{3-5})(6NIL.{3-6})(insert
 'cnt 'lst 'any) - 
lstInsertsanyintolstatpositioncnt.Thisisanon-destructiveoperation.Seealsoremove,place,append,deleteandreplace.:(insert3'(abcde)777)-(ab777cde):(insert1'(abcde)777)-(777abcde):(insert9'(abcde)777)-(abcde777)≪
 ↑ ↓ Viewing Ilibgpm: zero screen dimension, assuming 80x25.


 A signature in the sense of C or Java is perhaps

: (car insert)
- (N Lst X)

That probably what I was looking for.

 i.e. the formal parameters of the function.

Is there is similar method to get the formal parameters of a method?

,---
| :(class +Shape)   
| - +Shape 
|   
| :(dm T (X Y)  
| (=: x X)  
| (=: y Y)) 
| - T  
|   
| :(dm move (DX DY)
| (inc (:: x) DX)   
| (inc (:: y) DY))  
| - move  
|   
| :(car move)  
| !? (car move) 67291568 -- Variable expected ?
|   
| : (car 'move)
| - 67291568   
|   
| : (car insert)
| - (N Lst X)  
`---

Thanks for you answer

Cheers,
-- 
Thorsten

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


Re: How to get the signature of function and method definitions

2011-11-10 Thread Alexander Burger
Hi Thorsten,

  by looking at it with an editor (sorry, only 'vim' at the moment),
 
 : (vi 'insert)
 
 that was another question of mine - what would it take to get a
 
 ,
 | (emacs 'insert)
 `
 
 function, and a 
 
 ,---
 | (edit 'insert)
 `---
 
 that opens an emacs window?

Yes, this would be nice to have. I don't know enough about emacs, but
it should be surely possible.

For the first case, the source of 'vi' (lib/debug.l:162) could be taken
as a template.

The first expression

   (when (pair X)
  (setq C (cdr X)  X (car X)) )

occurs in a similar form in most debugging functions, and extracts a
possible class from the argument(s), i.e. calling (vi 'msg '+Cls) or
(vi '(msg . +Cls)) is the same. Then the file and line number is
searched in the '*Dbg' property of that symbol or class:

   (if C
  (get C '*Dbg -1 X)
  (get X '*Dbg 1) ) )

and also maintained in a local static variable *Vi for later
(repeated) calls and for 'ld'.

Then there is some tags file handling, don't know what makes
sense for emacs here.

The real call of 'vim' is

  (call 'vim
 (pack +set tags= (tmp tags) ,./tags)
 +set isk=33-34,36-38,42-90,92,94-95,97-125
 (pack + (car *Vi))
 (path (cdr *Vi)) )

Again, some tags fiddling, and the charset for symbols is set in 'isk'.

The most important part is the argument +123 (if the line number in the
file is 123) and the file's path name in the last two arguments to
'vim'.


'edit' is far more tricky, because it re-opens itself with additional
symbols which were clicked on. Perhaps we should think about it once
'vi' is ported to 'emacs'.


 : (doc 'insert)
 
 gives me this output - is that intended for vim too? (sorry for the long
 lines). 
 
 : (doc 'insert)
 1,02kbloaded-(208730594...

Dunno. This is strange.

By default, 'doc' simply calls the 'w3m' browser (if neither a browser
is in the environment variable BROWSER, nor one was passed as a second
argument to 'doc').


  A signature in the sense of C or Java is perhaps
 
 : (car insert)
 - (N Lst X)
 
 That probably what I was looking for.
 
  i.e. the formal parameters of the function.
 
 Is there is similar method to get the formal parameters of a method?
 
 ,---
 | :(class +Shape)   
 | - +Shape 
 |   
 | :(dm T (X Y)  
 | (=: x X)  
 | (=: y Y)) 
 | - T  
 |   
 | :(dm move (DX DY)
 | (inc (:: x) DX)   
 | (inc (:: y) DY))  
 | - move  
 |   
 | :(car move)  
 | !? (car move) 67291568 -- Variable expected ?
 |   
 | : (car 'move)
 | - 67291568   
 |   
 | : (car insert)
 | - (N Lst X)  
 `---

Yes, you could do

   : (car (method 'move '+Shape))
   - (DX DY)

(as you can do (pp 'move '+Shape) or (vi 'move '+Shape)).

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


Re: How to get the signature of function and method definitions

2011-11-10 Thread Thorsten
Alexander Burger a...@software-lab.de writes:

Hi Alex,

  by looking at it with an editor (sorry, only 'vim' at the moment),
 
 : (vi 'insert)
 
 that was another question of mine - what would it take to get a
 
 ,
 | (emacs 'insert)
 `
 
 function, and a 
 
 ,---
 | (edit 'insert)
 `---
 
 that opens an emacs window?

 Yes, this would be nice to have. I don't know enough about emacs, but
 it should be surely possible.

 For the first case, the source of 'vi' (lib/debug.l:162) could be taken
 as a template.

 The first expression

(when (pair X)
   (setq C (cdr X)  X (car X)) )

 occurs in a similar form in most debugging functions, and extracts a
 possible class from the argument(s), i.e. calling (vi 'msg '+Cls) or
 (vi '(msg . +Cls)) is the same. Then the file and line number is
 searched in the '*Dbg' property of that symbol or class:

(if C
   (get C '*Dbg -1 X)
   (get X '*Dbg 1) ) )

 and also maintained in a local static variable *Vi for later
 (repeated) calls and for 'ld'.

 Then there is some tags file handling, don't know what makes
 sense for emacs here.

 The real call of 'vim' is

   (call 'vim
  (pack +set tags= (tmp tags) ,./tags)
  +set isk=33-34,36-38,42-90,92,94-95,97-125
  (pack + (car *Vi))
  (path (cdr *Vi)) )

 Again, some tags fiddling, and the charset for symbols is set in 'isk'.

 The most important part is the argument +123 (if the line number in the
 file is 123) and the file's path name in the last two arguments to
 'vim'.

Ok, let me think about this, when I fully understand the 'vi' function I
might be able to produce an 'emacs' function, its a nice exercise.   

 'edit' is far more tricky, because it re-opens itself with additional
 symbols which were clicked on. Perhaps we should think about it once
 'vi' is ported to 'emacs'.

agreed.


 : (doc 'insert)
 
 gives me this output - is that intended for vim too? (sorry for the long
 lines). 
 
 : (doc 'insert)
 1,02kbloaded-(208730594...

 Dunno. This is strange.

 By default, 'doc' simply calls the 'w3m' browser (if neither a browser
 is in the environment variable BROWSER, nor one was passed as a second
 argument to 'doc').

I do use w3m and w3m-mode for emacs, and now I exported a new
environment variable BROWSER=w3m - and w3m seems to be on the path, since
I get the expected output when I type 'w3m' in a shell. But
nevertheless I get the same strange output in the emacs inferior
*picolisp* buffer. 

  A signature in the sense of C or Java is perhaps
 
 : (car insert)
 - (N Lst X)
 
 That probably what I was looking for.
 
  i.e. the formal parameters of the function.
 
 Is there is similar method to get the formal parameters of a method?
 
 ,---
 | :(class +Shape)   
 | - +Shape 
 |   
 | :(dm T (X Y)  
 | (=: x X)  
 | (=: y Y)) 
 | - T  
 |   
 | :(dm move (DX DY)
 | (inc (:: x) DX)   
 | (inc (:: y) DY))  
 | - move  
 |   
 | :(car move)  
 | !? (car move) 67291568 -- Variable expected ?
 |   
 | : (car 'move)
 | - 67291568   
 |   
 | : (car insert)
 | - (N Lst X)  
 `---

 Yes, you could do

: (car (method 'move '+Shape))
- (DX DY)

 (as you can do (pp 'move '+Shape) or (vi 'move '+Shape)).

I see, that works, still (very) much to learn ;)
Thanks for you help.

Cheers,
-- 
Thorsten

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


Re: how to get hold of function definition and related file

2011-04-29 Thread Tomas Hlavaty
Hi Alex,

 it also works with method definitions, if you pass the message and the
 class:
 
(vi 'put '+Entity)

 As an interesting exercise, to see what '*Dbg' actually stores, try
 this:

thank you for reminder,  I'll look into it.

Cheers,

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


how to get hold of function definition and related file

2011-04-28 Thread Tomas Hlavaty
Hi Alex,

some time ago you explained to me on #picolisp how do you get function
definitions into vim for editing.  Could you please remind me, where can
I find it again?  I would like to get hold of the function prg and file
and position where it was loaded from.  It was stored in some symbol
property when *Dbg iirc.

Thank you,

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


Re: how to get hold of function definition and related file

2011-04-28 Thread Alexander Burger
Hi Tomas,

 definitions into vim for editing.  Could you please remind me, where can
 I find it again?  I would like to get hold of the function prg and file
 and position where it was loaded from.  It was stored in some symbol
 property when *Dbg iirc.

Right. It is stored in the '*Dbg' property, but only if the system
was started in debug mode (i.e. with a trailing '+'):

   $ pil +

or (for a local installation)

   $ ./pil +

BTW, the local 'pil' replaced the 'p' in the current version. 'p' is a
little too cryptic, and 'pil' is compatible with the global 'pil' in
/usr/bin.

'./dbg' as an abbreviation for './pil +' will be kept for convenience,
but is not strictly required.


So when started in debug mode, the '*Dbg' property contains a
definition's filel name and line number, as returned by the 'file'
function.

That information can be used, for example, with the 'vi' function:

   (vi 'vi)

or

   (vi 'car)

it also works with method definitions, if you pass the message and the
class:

   (vi 'put '+Entity)

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


Re: how to get hold of function definition and related file

2011-04-28 Thread Alexander Burger
On Fri, Apr 29, 2011 at 07:23:11AM +0200, Alexander Burger wrote:
 it also works with method definitions, if you pass the message and the
 class:
 
(vi 'put '+Entity)

As an interesting exercise, to see what '*Dbg' actually stores, try
this:

   : (mapc println (get '+Entity '*Dbg))
   (760 . /usr/lib/picolisp/lib/db.l)
   (clone! 1090 . /usr/lib/picolisp/lib/db.l)
   (clone 1039 . /usr/lib/picolisp/lib/db.l)
   (set! 1009 . /usr/lib/picolisp/lib/db.l)
   (set 981 . /usr/lib/picolisp/lib/db.l)
   (keep! 970 . /usr/lib/picolisp/lib/db.l)
   (keep? 960 . /usr/lib/picolisp/lib/db.l)
   (keep 949 . /usr/lib/picolisp/lib/db.l)
   (keep1 945 . /usr/lib/picolisp/lib/db.l)
   (lose! 934 . /usr/lib/picolisp/lib/db.l)
   (lose 923 . /usr/lib/picolisp/lib/db.l)
   (lose1 919 . /usr/lib/picolisp/lib/db.l)
   (mis 916 . /usr/lib/picolisp/lib/db.l)
   (dec! 904 . /usr/lib/picolisp/lib/db.l)
   (dec 894 . /usr/lib/picolisp/lib/db.l)
   (inc! 882 . /usr/lib/picolisp/lib/db.l)
   (inc 872 . /usr/lib/picolisp/lib/db.l)
   (del! 861 . /usr/lib/picolisp/lib/db.l)
   (del 852 . /usr/lib/picolisp/lib/db.l)
   (put! 840 . /usr/lib/picolisp/lib/db.l)
   (put 830 . /usr/lib/picolisp/lib/db.l)
   (has 825 . /usr/lib/picolisp/lib/db.l)
   (upd 823 . /usr/lib/picolisp/lib/db.l)
   (url 821 . /usr/lib/picolisp/lib/db.l)
   (zap 816 . /usr/lib/picolisp/lib/db.l)
   (T 808 . /usr/lib/picolisp/lib/db.l)

It shows that the class '+Entity' is stored in line 760 of lib/db.l,
and then the locations of all methods of that class.

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


Re: put, applying get algorithm

2010-08-29 Thread Jon Kleiser
 I never saw the ; shortcut being mentioned, in most cases (for me
 anyway) it will suffice instead of get.

By the way, is the ';' functionally identical to the 'get'? If so, I think
the docs should say so clearly. If not so, what's the difference?

/Jon

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


Re: put, applying get algorithm

2010-08-29 Thread Alexander Burger
Hi Jon,

  I never saw the ; shortcut being mentioned, in most cases (for me
  anyway) it will suffice instead of get.
 
 By the way, is the ';' functionally identical to the 'get'?

Yes, except for whether (or which) arguments are evaluated. This is
along the same line as 'get' - ':', 'prop' - '::' and 'put' - '=:'
etc.

Thus, ':' and ';' are just shorter and faster variations of 'get'.

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


Re: put, applying get algorithm

2010-08-27 Thread Jon Kleiser

On 8/26/10 1:20 PM, Alexander Burger wrote:
..

I'm not sure about the docs, as such examples - as you can see above -
quickly get rather complicated.

Cheers,
- Alex


I think this could be a nice little example:

: (setq L '(A B C))
- (A B C)
: (setq B 'D)
- D
: (put L 2 0 'p 5)
- 5
: (getl 'D)
- ((5 . p))

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


Re: put, applying get algorithm

2010-08-27 Thread Alexander Burger
Hi Jon,

 I think this could be a nice little example:
 
 : (setq L '(A B C))
 - (A B C)
 : (setq B 'D)
 - D
 : (put L 2 0 'p 5)
 - 5
 : (getl 'D)
 - ((5 . p))

Indeed! I included it. Many thanks!

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


Re: put, applying get algorithm

2010-08-27 Thread Henrik Sarvell
I never saw the ; shortcut being mentioned, in most cases (for me
anyway) it will suffice instead of get.


On Fri, Aug 27, 2010 at 6:00 PM, Alexander Burger a...@software-lab.de wrote:
 Hi Jon,

 I think this could be a nice little example:

 : (setq L '(A B C))
 - (A B C)
 : (setq B 'D)
 - D
 : (put L 2 0 'p 5)
 - 5
 : (getl 'D)
 - ((5 . p))

 Indeed! I included it. Many thanks!

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

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


put, applying get algorithm

2010-08-26 Thread Jon Kleiser

Hi,

In the docs on the 'put' function I read this:

That symbol is sym1 (if no other arguments are given), or a symbol found 
by applying the get algorithm to sym1|lst and the following arguments.


Could somebody give me an example or two where this get algorithm is 
being applied? Maybe Alex could put it into the docs ...?


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


Re: put, applying get algorithm

2010-08-26 Thread Alexander Burger
Hi Jon,

 That symbol is sym1 (if no other arguments are given), or a symbol
 found by applying the get algorithm to sym1|lst and the following
 arguments.
 
 Could somebody give me an example or two where this get algorithm is
 being applied? Maybe Alex could put it into the docs ...?

This is used a lot in database applications, where objects are
interconnected with each other via +Link and +Joint relations.


As a conceived example, let's create in-memory objects instead:

(put 'Supplier 'name Tools Inc.)
(put 'Supplier 'street Main Street)
(put 'Supplier 'city New York)

(put 'Article1 'name Toolset)
(put 'Article1 'supplier 'Supplier)

(put 'Article2 'name Chainsaw)
(put 'Article2 'supplier 'Supplier)

(put 'Order 'number 17)
(put 'Order 'articles '(Article1 Article2))

(put 'Customer 'name Jon)
(put 'Customer 'orders '(Order))


# This prints Tools Inc.
(prinl
   (get 'Customer 'orders 1 'articles 2 'supplier 'name) )

# This prints Main Street
(prinl
   (get 'Customer 'orders 1 'articles 2 'supplier 'street) )

# Set another street name
(put 'Customer 'orders 1 'articles 2 'supplier 'street New Street)

# Then this prints New Street
(prinl
   (get 'Customer 'orders 1 'articles 2 'supplier 'street) )


So the 'put' statement 4 lines above uses a 'get' chain to find the
desired object, then stores the new property.


Note that in applications 'put' and 'get' are actually not often used.

Instead of 'get' you'll typically see derivates like ':', because most
interactions happen in methods or 'with' bodies, where the 'This' object
is bound:

# This also prints the current street, but is smaller and faster
# than the above 'get' statement
(with 'Customer
   (prinl
  (: orders 1 articles 2 supplier street) ) )


Instead of 'put', 'put' and 'put!' are used to store database
properties (which unfortunately don't support the above 'get' chains),
so something like

   (put (: orders 1 articles 2 supplier) 'street New Street)

is required. Not a  big drawback, though.


I'm not sure about the docs, as such examples - as you can see above -
quickly get rather complicated.

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


Re: put, applying get algorithm

2010-08-26 Thread Alexander Burger
 On 8/26/10 1:20 PM, Alexander Burger wrote:
 As a conceived example, let's create in-memory objects instead:

For the sake of completeness: The 'put' statement in the example

   (put 'Customer 'orders 1 'articles 2 'supplier 'street New Street)

becomes

   (with 'Customer
  (=: orders 1 articles 2 supplier street New Street) )

when using the short-hand functions.

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