From: Jens Teich
Subject: problem with infinite loop
Date: 
Message-ID: <ups27ocas.fsf@jensteich.de>
this ...

| (defun e-guid-list->property-records (lang p-guid-list)
|   (loop for e
|         in (mapcar #'(lambda (p) (product-element
|                                   (find-element p lang)))
|                    p-guid-list)
|         when e
|         nconc (product-property e)))

... works only once. The second time it is sent into infinity.

The called functions are well tested and work on their own.

Any ideas? 

Further information required?

Thanks
Jens

From: Jens Teich
Subject: Re: problem with infinite loop
Date: 
Message-ID: <ulkcvobss.fsf@jensteich.de>
Jens Teich <····@jensteich.de> writes:

> this ...
>
> | (defun e-guid-list->property-records (lang p-guid-list)
> |   (loop for e
> |         in (mapcar #'(lambda (p) (product-element
> |                                   (find-element p lang)))
> |                    p-guid-list)
> |         when e
> |         nconc (product-property e)))
>
> ... works only once. The second time it is sent into infinity.
>
> The called functions are well tested and work on their own.
>
> Any ideas? 
>
> Further information required?

| (defun find-element
|         (&optional (element-guid *root-guid*) (lang *default-lang*))
|   (caar
|    (or (clsql:select 'elemente
|                      :where
|                      [and [= [slot-value 'elemente 'lang_id] lang]
|                           [= [slot-value 'elemente 'guid]    element-guid]])
|        (error "nothing found"))))

| (clsql:def-view-class elemente ()
|   ((guid    :reader element-guid :db-kind :key  :type (string 36))
|    (lang_id                      :db-kind :key  :type (string 2))
|    (type_id :reader type-id      :db-kind :base :type string)
|    (guid_objekt  :reader eguid-objekt      :db-kind :base :type (string 36))
|    (struct_guid_parent_node      :db-kind :base :type (string 36))
|    (name    :reader element-name                :type string)
|    (children
|     :reader children
|     :db-kind :join
|     :db-info (:join-class elemente
|               :home-key (guid lang_id)
|               :foreign-key (struct_guid_parent_node lang_id)
|               :set t))
|    (father
|     :reader father
|     :db-kind :join
|     :db-info (:join-class elemente
|               :foreign-key (guid lang_id)
|               :home-key (struct_guid_parent_node lang_id)
|               :set nil))
|    (produkt
|     :reader produkt-element
|     :db-kind :join
|     :db-info (:join-class produkte
|               :home-key (guid_objekt lang_id)
|               :foreign-key (guid lang_id)
|               :set nil)))
|   (:base-table projekt-elemente))
| 
| (clsql:def-view-class produkte ()
|   ((guid                         :db-kind :key :type (string 36))
|    (lang_id                      :db-kind :key :type (string 2))
|    (name      :reader produkt-name             :type string)
|    (merkmale
|     :reader produkt-merkmale
|     :db-kind :join
|     :db-info (:join-class merkmale
|               :home-key (guid lang_id)
|               :foreign-key (guid_produkt_reihe_merkmal lang_id)))
|    (element
|     :reader produkt-element
|     :db-kind :join
|     :db-info (:join-class elemente
|               :home-key (guid lang_id)
|               :foreign-key (guid_objekt lang_id)))
|    (x-abbildungen
|     :reader produkt-x-abbildungen
|     :db-kind :join
|     :db-info (:join-class  x-abbildungen
|               :home-key    guid
|               :foreign-key guid_objekt)))
|               ;; :target-slot abbildung)))
|   (:base-table produkte_reihen))

> Thanks
> Jens
From: Jens Teich
Subject: Re: problem with infinite loop
Date: 
Message-ID: <uhcnjobkk.fsf@jensteich.de>
sorry to answer twice on my own post

I mixed German and English names. In the first post I tried to translate my
German symbol-names into English. The second post contains German symbol-names.

Don't care about differences
produkt product
merkmal property
...

Jens
From: Edi Weitz
Subject: Re: problem with infinite loop
Date: 
Message-ID: <ups27ziqn.fsf@agharta.de>
On Wed, 01 Aug 2007 11:04:59 +0200, Jens Teich <····@jensteich.de> wrote:

> this ...
>
> | (defun e-guid-list->property-records (lang p-guid-list)
> |   (loop for e
> |         in (mapcar #'(lambda (p) (product-element
> |                                   (find-element p lang)))
> |                    p-guid-list)
> |         when e
> |         nconc (product-property e)))
>
> ... works only once.

Try if the problems go away if you replace NCONC with APPEND.

Edi.


-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Jens Teich
Subject: Re: problem with infinite loop
Date: 
Message-ID: <ud4y7o9do.fsf@jensteich.de>
> Try if the problems go away if you replace NCONC with APPEND.

Doesn't help. Same behaviour.

Jens
From: John Thingstad
Subject: Re: problem with infinite loop
Date: 
Message-ID: <op.twdqllvbpqzri1@pandora.upc.no>
P� Wed, 01 Aug 2007 11:04:59 +0200, skrev Jens Teich <····@jensteich.de>:

>
> this ...
>
> | (defun e-guid-list->property-records (lang p-guid-list)
> |   (loop for e
> |         in (mapcar #'(lambda (p) (product-element
> |                                   (find-element p lang)))
> |                    p-guid-list)
> |         when e
> |         nconc (product-property e)))
>

I would try

(loop for e in ...
    when e collect (product-property (copy-seq e)) as result
    finally (nreverse result))

The push, nreverse idiom is faster and not doing in-place operations  
avoids side-effects.
Also the (copy-seq e) is there to avoid side effects.
From: John Thingstad
Subject: Re: problem with infinite loop
Date: 
Message-ID: <op.twdqzbevpqzri1@pandora.upc.no>
P� Wed, 01 Aug 2007 14:06:47 +0200, skrev John Thingstad  
<··············@chello.no>:

> P� Wed, 01 Aug 2007 11:04:59 +0200, skrev Jens Teich <····@jensteich.de>:
>
>>
>> this ...
>>
>> | (defun e-guid-list->property-records (lang p-guid-list)
>> |   (loop for e
>> |         in (mapcar #'(lambda (p) (product-element
>> |                                   (find-element p lang)))
>> |                    p-guid-list)
>> |         when e
>> |         nconc (product-property e)))
>>
>
> I would try
>
> (loop for e in ...
>     when e collect (product-property (copy-seq e)) as result
>     finally (nreverse result))
>
> The push, nreverse idiom is faster and not doing in-place operations  
> avoids side-effects.
> Also the (copy-seq e) is there to avoid side effects.

Arg! forget that.. Brain fart.
More like this.

(mapcan (lambda (e) (when e (product-property e)) (mapcar (lambda (p)  
(product-element p lang)) p-guid-list))
From: Jens Teich
Subject: Re: problem with infinite loop
Date: 
Message-ID: <u8x8vnv1y.fsf@jensteich.de>
"John Thingstad" <··············@chello.no> writes:

> P� Wed, 01 Aug 2007 14:06:47 +0200, skrev John Thingstad
> <··············@chello.no>:
>
>> P� Wed, 01 Aug 2007 11:04:59 +0200, skrev Jens Teich <····@jensteich.de>:
>>
>>>
>>> this ...
>>>
>>> | (defun e-guid-list->property-records (lang p-guid-list)
>>> |   (loop for e
>>> |         in (mapcar #'(lambda (p) (product-element
>>> |                                   (find-element p lang)))
>>> |                    p-guid-list)
>>> |         when e
>>> |         nconc (product-property e)))
>>>
>>
>> I would try
>>
>> (loop for e in ...
>>     when e collect (product-property (copy-seq e)) as result
>>     finally (nreverse result))
>>
>> The push, nreverse idiom is faster and not doing in-place operations
>> avoids side-effects.
>> Also the (copy-seq e) is there to avoid side effects.
>
> Arg! forget that.. Brain fart.
> More like this.
>
> (mapcan (lambda (e) (when e (product-property e)) (mapcar (lambda (p)
> (product-element p lang)) p-guid-list))

Thanks for this suggestion. Looks as if something behind the scenes is
happening. Unicode data is part of the problem and I get an error

| SB-INT:STREAM-ENCODING-ERROR

which kills the slime session and is only visible in the sbcl (via screen).
sbcl runs stable.

Jens