Hi Henrik,

On Fri, Jan 08, 2010 at 02:30:07PM +0100, Alexander Burger wrote:
>    : (setq Sock (connect "localhost" 4040))
>    -> 17
>    : (out Sock (pr (list 'collect ''nr ''+Item 2 5 ''nr)))
>    -> (collect 'nr '+Item 2 5 'nr)
>    : (in Sock (rd))
>    -> (2 3 4 5)

This is not completely correct. It works here, as only the item numbers
are returned from the remote server. But if (as in the example using the
Pilog 'remote' query) the remote objects are accessed locally

   : (solve
      (quote
         @Nm "Part"
         @Rsrc (rsrc)
         (remote (@Item . @Rsrc)
            (db nm +Item @Nm @Item) ) )
      @Item )
   -> ({L-1} {L-2})

   : (show '{L-1})                                                              
  {L-1} (+Item)
      pr 29900
      inv 100
      sup {K-1}
      nm Main Part
      nr 1
   -> {L-1}

then the above equivalent sequence

   : (out Sock (pr (list 'collect ''nr ''+Item 1 2)))
   -> (collect 'nr '+Item 1 2)
   : (in Sock (rd))
   -> ({3-1} {3-2})

Returns the objects without the translation to local form via '*Ext'
(i.e. {3-1} instead of {L-1}). Accessing them gives an error

   : (show '{3-1})
   !? (val X)
   Bad DB file
   {3-1} ?


So the right way would be using 'ext' (in both directions to be on the
safe side):

   : (out Sock (ext 20 (pr (list 'collect ''nr ''+Item 1 2))))
   -> (collect 'nr '+Item 1 2)
   : (in Sock (ext 20 (rd)))
   -> ({L-1} {L-2})

The number 20 is the offset, as used by '*Ext' and 'rsrc'.

For a real application, you will want encapsulate and abstract all the
explained procedures. I used a class called '+Agent' handling all
connections to remote servers, socket I/O and 'ext' handling.

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

Reply via email to