Re: autogenerated keys for pilog

2011-03-31 Thread Jakob Eriksson
On Thu, Mar 31, 2011 at 09:57:06AM +0800, Edwin Eyan Moragas wrote:
 Hi List,
 
 what's the best way to go about autogenerated keys for Pilog? i've
 been digging around a bit and can't find anything related.
 
 hints and pointers would be most appreciated. thank you.


Hi!

I have copied your (very good) question to:
http://stackoverflow.com/questions/5496015/autogenerated-keys-in-pilog

As I want to promote the Picolisp language on that site, but I have a hard time 
thinking up good questions and answers on my own.

best regards,
Jakob
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: autogenerated keys for pilog

2011-03-31 Thread Henrik Sarvell
You get the same behavior as auto increment in for instance MySQL with this
one: http://software-lab.de/doc/refG.html#genKey

I use it a lot in the VizReader code.

I'm not so sure I would've used it much though if I had know about the (id)
function from the start: http://software-lab.de/doc/refI.html#id

In my case it's all about displaying a nice id that is easy to relate for
humans and JavaScript in my non-traditional gui and as you can see both
approaches accomplish that but that latter is imo more elegant.

/Henrik Sarvell


On Thu, Mar 31, 2011 at 1:26 PM, Jakob Eriksson ja...@vmlinux.org wrote:

 On Thu, Mar 31, 2011 at 09:57:06AM +0800, Edwin Eyan Moragas wrote:
  Hi List,
 
  what's the best way to go about autogenerated keys for Pilog? i've
  been digging around a bit and can't find anything related.
 
  hints and pointers would be most appreciated. thank you.


 Hi!

 I have copied your (very good) question to:
 http://stackoverflow.com/questions/5496015/autogenerated-keys-in-pilog

 As I want to promote the Picolisp language on that site, but I have a hard
 time thinking up good questions and answers on my own.

 best regards,
 Jakob
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe



Re: autogenerated keys for pilog

2011-03-31 Thread Edwin Eyan Moragas
H Alex,

On Thu, Mar 31, 2011 at 2:42 PM, Alexander Burger a...@software-lab.de wrote:
 Hi Edwin,

 what's the best way to go about autogenerated keys for Pilog? i've
 been digging around a bit and can't find anything related.

 Hmm, I am not sure what that is. You mean something along autogenerated
 keys in JDBC? I find

   JDBC's auto-generated keys feature provides a way to retrieve values
   from columns that are part of an index or have a default value
   assigned


 In the PicoLisp DB there are no keys used to join tables. Instead,
 objects are directly linked, i.e. they refer to each other (in
 properties) by containing other objets, or lists of objects.

check. another insight. thank you.


 The relation maintenance classes for that are '+Link' and '+Joint'.


 In fact, there is a function 'genKey' which generates keys, but this is
 different from how I understand the above autogenerated keys. 'genKey'
 simply returns a new number not yet existent in an index.

i think this hits the nail squarely.


 Can you give an example what you'd like to do?

suppose there is a song entitled evergreen. one was sung by barbra
streisand, the other by will young. different lyrics, but same song
title.

i'd like to use SongTitle as a key, but it won;t cut it, as in the
example above. so i have to revert to something like an autoincrement
key.

this is it! thank you.


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

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


understanding (id) (was Re: autogenerated keys for pilog)

2011-03-31 Thread Edwin Eyan Moragas
Hi Henrik,

On Thu, Mar 31, 2011 at 2:48 PM, Henrik Sarvell hsarv...@gmail.com wrote:
 You get the same behavior as auto increment in for instance MySQL with this
 one: http://software-lab.de/doc/refG.html#genKey

 I use it a lot in the VizReader code.

great. thank you.


 I'm not so sure I would've used it much though if I had know about the (id)
 function from the start: http://software-lab.de/doc/refI.html#id

i'd like to understand this more. can you please give an illustration
on how to do this?


 In my case it's all about displaying a nice id that is easy to relate for
 humans and JavaScript in my non-traditional gui and as you can see both
 approaches accomplish that but that latter is imo more elegant.

 /Henrik Sarvell


 On Thu, Mar 31, 2011 at 1:26 PM, Jakob Eriksson ja...@vmlinux.org wrote:

 On Thu, Mar 31, 2011 at 09:57:06AM +0800, Edwin Eyan Moragas wrote:
  Hi List,
 
  what's the best way to go about autogenerated keys for Pilog? i've
  been digging around a bit and can't find anything related.
 
  hints and pointers would be most appreciated. thank you.


 Hi!

 I have copied your (very good) question to:
 http://stackoverflow.com/questions/5496015/autogenerated-keys-in-pilog

 As I want to promote the Picolisp language on that site, but I have a hard
 time thinking up good questions and answers on my own.

 best regards,
 Jakob
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


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


Re: autogenerated keys for pilog

2011-03-31 Thread Alexander Burger
Hi Edwin,

  In fact, there is a function 'genKey' which generates keys, but this is
  different from how I understand the above autogenerated keys. 'genKey'
  simply returns a new number not yet existent in an index.
 
 i think this hits the nail squarely.

OK, good! I just misunderstood the autogenerated keys.


 suppose there is a song entitled evergreen. one was sung by barbra
 streisand, the other by will young. different lyrics, but same song
 title.
 
 i'd like to use SongTitle as a key, but it won;t cut it, as in the
 example above. so i have to revert to something like an autoincrement
 key.

I see. So indeed 'genKey' can be used to generate some unique key.

Another option, as you know, might be to define SongTitle as a
non-unique key (+Ref), and build a unique key combination by '+Aux'ing
the artist.

It is not necessary, btw, for an Entity to have any unique key at all.
You can 'collect' all songs with a non-unique SongTitle, or find them
with Pilog.


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


Re: autogenerated keys for pilog

2011-03-31 Thread Ana Zgombic
On Thu, Mar 31, 2011 at 3:34 PM, Alexander Burger a...@software-lab.de wrote:
 Hi Edwin,

  In fact, there is a function 'genKey' which generates keys, but this is
  different from how I understand the above autogenerated keys. 'genKey'
  simply returns a new number not yet existent in an index.

 i think this hits the nail squarely.

 OK, good! I just misunderstood the autogenerated keys.


 suppose there is a song entitled evergreen. one was sung by barbra
 streisand, the other by will young. different lyrics, but same song
 title.

 i'd like to use SongTitle as a key, but it won;t cut it, as in the
 example above. so i have to revert to something like an autoincrement
 key.

 I see. So indeed 'genKey' can be used to generate some unique key.

 Another option, as you know, might be to define SongTitle as a
 non-unique key (+Ref), and build a unique key combination by '+Aux'ing
 the artist.

 It is not necessary, btw, for an Entity to have any unique key at all.
 You can 'collect' all songs with a non-unique SongTitle, or find them
 with Pilog.


discussions like these makes lurking lovely. add to that understanding
how things work more deeply.


-- 
http://nybl.info
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: understanding (id) (was Re: autogenerated keys for pilog)

2011-03-31 Thread Alexander Burger
Hi Edwin,

  I'm not so sure I would've used it much though if I had know about the (id)
  function from the start: http://software-lab.de/doc/refI.html#id
 
 i'd like to understand this more. can you please give an illustration
 on how to do this?

Sorry, this is my fault. The reference gives no explanation what 'id' is
for.

It assumes some understanding on how objects are stored in databases.
Each object is stored in a file, at a given block-offset. That offset
never changes during the lifetime of an object. It is used to fetch that
object's data from the file, and write changes to the file.

This can be seen also in an external symbol's name: If it resides in
block number 7 of file number 3, it will print as '{3-7}' on 32-bits and
'{B7}' on 64-bits (the two systems differ here).

Now what 'id' does is return such a symbol's file number and offset, or
do the opposite operation (returning that symbol if given a block offset
and a file number). As these numbers are a unique reference to that
symbol, they are useful in some contexts, e.g. when communicating an
object to the external world (e.g. a module written in another
language). Within a single database, or also distributed databases, 'id'
is not necessary as the symbol can be directly communicated.

Perhaps Henrik can give a use case example?

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


Re: understanding (id) (was Re: autogenerated keys for pilog)

2011-03-31 Thread Henrik Sarvell
I use a lot of asynchronous information going back and forth and to avoid
problems with escaping wavy brackets in JSON and/or other problems that
might arise from using non alpha numericals as a part of an id it's more
convenient to use a number than the actual location of the object.

This can be achieved with either (genKey) or (id). The genKey scenario is
better if you also want to be able to view/manipulate the data through the
traditional GUI.

Id mainly enters the picture in the distributed word index:
http://picolisp.com/5000/-2-I.html



On Thu, Mar 31, 2011 at 8:32 PM, Alexander Burger a...@software-lab.dewrote:

 Hi Edwin,

   I'm not so sure I would've used it much though if I had know about the
 (id)
   function from the start: http://software-lab.de/doc/refI.html#id
 
  i'd like to understand this more. can you please give an illustration
  on how to do this?

 Sorry, this is my fault. The reference gives no explanation what 'id' is
 for.

 It assumes some understanding on how objects are stored in databases.
 Each object is stored in a file, at a given block-offset. That offset
 never changes during the lifetime of an object. It is used to fetch that
 object's data from the file, and write changes to the file.

 This can be seen also in an external symbol's name: If it resides in
 block number 7 of file number 3, it will print as '{3-7}' on 32-bits and
 '{B7}' on 64-bits (the two systems differ here).

 Now what 'id' does is return such a symbol's file number and offset, or
 do the opposite operation (returning that symbol if given a block offset
 and a file number). As these numbers are a unique reference to that
 symbol, they are useful in some contexts, e.g. when communicating an
 object to the external world (e.g. a module written in another
 language). Within a single database, or also distributed databases, 'id'
 is not necessary as the symbol can be directly communicated.

 Perhaps Henrik can give a use case example?

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



autogenerated keys for pilog

2011-03-30 Thread Edwin Eyan Moragas
Hi List,

what's the best way to go about autogenerated keys for Pilog? i've
been digging around a bit and can't find anything related.

hints and pointers would be most appreciated. thank you.

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