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

Reply via email to