Strange error with WAHtmlAttributes>>writeKey:value:on:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange error with WAHtmlAttributes>>writeKey:value:on:

Hilaire Fernandes-3
With the following code snippet:


(html select)
        list: entities;
        selected: (entities ifNotEmpty: [selectedEditEntity := entities first]);
        labels: [:entity | entity entityName];
        callback: [:anEntity | selectedEditEntity := anEntity]


When entity are IFIAdult object with the = and hash methods implemented
I have the following error bellow.


It looks like the following code in writeKey:value:on: is causing the error:

writeKey: aKey value: aValue on: aStream
        aValue = false ifFalse: [
[...]

Indeed the debugger tells me aValue is an IFIAdult instance which does
not expect to be compared to a boolean.

Before I wrote the = method it was working fine.

Hilaire



MessageNotUnderstood: False>>entityName

     * False(Object)>>doesNotUnderstand: #entityName

           self false
           temps
           aMessage entityName

     * IFIAdult(IFIPerson)>>=

           self an IFIAdult
           temps
           person false
           inst vars
           lastName 'Fernandes'
           firstName 'Hilaire'
           picture nil
           email nil
           id 13864597
           functions an OrderedCollection(#teacher)

     * WAHtmlAttributes>>writeKey:value:on:

           self a WAHtmlAttributes
           temps
           aKey 'selected'
           aValue an IFIAdult
           aStream a RWBinaryOrTextStream '
           inst vars
           attributes a Dictionary('selected'->an IFIAdult 'value'->'4' )

     * [] in WAHtmlAttributes>>writeOn: {[:key :value | self writeKey:
key asLowercase value: value on: aStream]}

           self a WAHtmlAttributes
           temps
           aStream a RWBinaryOrTextStream '
           key 'selected'
           value an IFIAdult
           inst vars
           attributes a Dictionary('selected'->an IFIAdult 'value'->'4' )

     * [] in Dictionary>>keysAndValuesDo: {[:assoc | aBlock value: assoc
key value: assoc value]}

           self a Dictionary('selected'->an IFIAdult 'value'->'4' )
           temps
           aBlock [] in WAHtmlAttributes>>writeOn: {[:key :value | self
writeKey: key asLowercase value: value o...etc...
           assoc 'selected'->an IFIAdult
           inst vars
           tally 2
           array #(nil nil 'selected'->an IFIAdult nil 'value'->'4' nil)

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Strange error with WAHtmlAttributes>>writeKey:value:on:

Philippe Marschall
2007/4/3, Hilaire Fernandes <[hidden email]>:

> With the following code snippet:
>
>
> (html select)
>         list: entities;
>         selected: (entities ifNotEmpty: [selectedEditEntity := entities first]);
>         labels: [:entity | entity entityName];
>         callback: [:anEntity | selectedEditEntity := anEntity]
>
>
> When entity are IFIAdult object with the = and hash methods implemented
> I have the following error bellow.
>
>
> It looks like the following code in writeKey:value:on: is causing the error:
>
> writeKey: aKey value: aValue on: aStream
>         aValue = false ifFalse: [
> [...]

Does IFIPerson >> #= send #isKindOf:? If not add it.

Philippe.

> Indeed the debugger tells me aValue is an IFIAdult instance which does
> not expect to be compared to a boolean.
>
> Before I wrote the = method it was working fine.
>
> Hilaire
>
>
>
> MessageNotUnderstood: False>>entityName
>
>      * False(Object)>>doesNotUnderstand: #entityName
>
>            self false
>            temps
>            aMessage     entityName
>
>      * IFIAdult(IFIPerson)>>=
>
>            self an IFIAdult
>            temps
>            person       false
>            inst vars
>            lastName     'Fernandes'
>            firstName    'Hilaire'
>            picture      nil
>            email        nil
>            id   13864597
>            functions    an OrderedCollection(#teacher)
>
>      * WAHtmlAttributes>>writeKey:value:on:
>
>            self a WAHtmlAttributes
>            temps
>            aKey 'selected'
>            aValue       an IFIAdult
>            aStream      a RWBinaryOrTextStream '
>            inst vars
>            attributes   a Dictionary('selected'->an IFIAdult 'value'->'4' )
>
>      * [] in WAHtmlAttributes>>writeOn: {[:key :value | self writeKey:
> key asLowercase value: value on: aStream]}
>
>            self a WAHtmlAttributes
>            temps
>            aStream      a RWBinaryOrTextStream '
>            key  'selected'
>            value        an IFIAdult
>            inst vars
>            attributes   a Dictionary('selected'->an IFIAdult 'value'->'4' )
>
>      * [] in Dictionary>>keysAndValuesDo: {[:assoc | aBlock value: assoc
> key value: assoc value]}
>
>            self a Dictionary('selected'->an IFIAdult 'value'->'4' )
>            temps
>            aBlock       [] in WAHtmlAttributes>>writeOn: {[:key :value | self
> writeKey: key asLowercase value: value o...etc...
>            assoc        'selected'->an IFIAdult
>            inst vars
>            tally        2
>            array        #(nil nil 'selected'->an IFIAdult nil 'value'->'4' nil)
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Strange error with WAHtmlAttributes>>writeKey:value:on:

Hilaire Fernandes-3
Philippe Marschall a écrit :

>> (html select)
>>         list: entities;
>>         selected: (entities ifNotEmpty: [selectedEditEntity :=
>> entities first]);
>>         labels: [:entity | entity entityName];
>>         callback: [:anEntity | selectedEditEntity := anEntity]
>>
>>
>> When entity are IFIAdult object with the = and hash methods implemented
>> I have the following error bellow.
>>
>>
>> It looks like the following code in writeKey:value:on: is causing the
>> error:
>>
>> writeKey: aKey value: aValue on: aStream
>>         aValue = false ifFalse: [
>> [...]
>
> Does IFIPerson >> #= send #isKindOf:? If not add it.

No as I thought it was bad behavior (kind of slowing things).

Hilaire

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Strange error with WAHtmlAttributes>>writeKey:value:on:

Michael Roberts-2
>> Does IFIPerson >> #= send #isKindOf:? If not add it.
>
> No as I thought it was bad behavior (kind of slowing things).

If you look in a squeak image at all the implementors of #= you will  
see that there are various ways of doing it.  Some say self class ==  
other class, some self species = other species, and some isKindOf:

I would have thought that you need at least one guard along these  
lines otherwise how do you know that apples aren't oranges?  As for  
speed I'm sure you can measure the choices in some manner.

Cheers,

Mike



_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Strange error with WAHtmlAttributes>>writeKey:value:on:

Philippe Marschall
In reply to this post by Hilaire Fernandes-3
2007/4/3, Hilaire Fernandes <[hidden email]>:

> Philippe Marschall a écrit :
>
> >> (html select)
> >>         list: entities;
> >>         selected: (entities ifNotEmpty: [selectedEditEntity :=
> >> entities first]);
> >>         labels: [:entity | entity entityName];
> >>         callback: [:anEntity | selectedEditEntity := anEntity]
> >>
> >>
> >> When entity are IFIAdult object with the = and hash methods implemented
> >> I have the following error bellow.
> >>
> >>
> >> It looks like the following code in writeKey:value:on: is causing the
> >> error:
> >>
> >> writeKey: aKey value: aValue on: aStream
> >>         aValue = false ifFalse: [
> >> [...]
> >
> > Does IFIPerson >> #= send #isKindOf:? If not add it.
>
> No as I thought it was bad behavior
It's bad everywhere but in #= (and tests).

> (kind of slowing things).

premature optimization
especially if you're doing string comparison afterwards

Philippe

> Hilaire
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside