[vwnc] Code compiled in the wrong namespace

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

[vwnc] Code compiled in the wrong namespace

reinier van oosten-2
Dear list,

I am working on code generation. In this work I found a compilation problem. 

I try to compile conditionally a class in a namespace. If there is no class of that name in an imported namespace, there is no problem. However in the next case the class did not compile.

Generated code:

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it package="Lb-domain">LbTest ifNil:[ Smalltalk defineNameSpace: 'LbTest' private: false
        imports: 'private Smalltalk.* private XML.* private GIPA.* ' category: 'Lb-domain'
        attributes: #( #(#package 'Lb-domain'))]</do-it>
    <do-it package="Lb-domain">Smalltalk at: 'LbTest.Event' ifAbsent: [LbTest defineClass: #Event
        superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ' '
        classInstanceVariableNames: ' ' imports: ' ' category: 'Lb-domain' attributes: #(#(#package
        'Lb-domain'))]</do-it>
</st-source>

First I define, if necessary, the namespace LbTest. Then I create the class LbTest.Event. 
The result in the changes file shows that the namespace is created, however the class is not. I also created a class LbTest.Meet, which was created.

The following piece of code and the way the system is reacting on it is more disturbing.

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it package="Lb-domain">LbTest.Event addInstVarName: 'daytime'</do-it>
    <methods>
        <class-id>LbTest.Event</class-id>
        <category>attribute-accessing</category>
        <body package="Lb-domain" selector="daytime:">
daytime: anObject
    "This is generated code from GIPA for attribute daytime
    GIPA is developed by Reinier van Oosten [hidden email] "
   
    | theObject |
    theObject := anObject.
    (theObject isKindOf: Core.Time) ifFalse:[self error: 'Wrong type for attribute daytime'].
    daytime := theObject</body>
    <body package="Lb-domain" selector="daytime">
daytime
    "This is generated code from GIPA for attribute daytime
    GIPA is developed by Reinier van Oosten [hidden email] "
    ^daytime</body>
    </methods>
</st-source>

I add the variable daytime to the class LbTest.Event and add some methods to that class. The log from the changes are very informative however unexpected.
I show here the entries in the changeList tool

Smalltalk.UI defineClass: #Event
superclass: #{Core.Object}
indexedType: #none
private: false
instanceVariableNames: 'time initiator window daytime '
classInstanceVariableNames: ''
imports: ''
category: 'Interface-Events'
attributes: #(
#(#package 'Interface-Events'))

daytime: anObject
"This is generated code from GIPA for attribute daytime
GIPA is developed by Reinier van Oosten
"
| theObject |
theObject := anObject.
(theObject isKindOf: Core.Time) 
ifFalse:[self error: 'Wrong type for attribute daytime'].
daytime := theObject

daytime
"This is generated code from GIPA for attribute daytime
GIPA is developed by Reinier van Oosten
"
^daytime

Apparently the system finds the class Smalltalk.UI.Event, and instead of creating a new class LbTest.Event it works with UI.Event.
This is not expected and for sure not something you want.

Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

tel: 079-3437073
gsm: 0651335993




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Code compiled in the wrong namespace

thomas.hawker

Reinier,

 

I think your class creation do-it is incorrect.  You start with the test:

 

Smalltalk at: ‘LbTest.Event’ ifAbsent: […]

 

Smalltalk won’t find the string ‘LbTest.Event’ – that is, as a name space, Smalltalk only has keys of symbols, and they are completely unqualified.  Thus, the name space UI, under Smalltalk, exists with key #OS, etc.

 

What I think you want is a test like this instead:

 

#{LbTest.Event} isDefined ifFalse: […]

 

You want to resolve the name #Event in the context of its namespace, #LbTest, so you have to use a qualified reference.  Otherwise, as it did, it will resolve the name #Event to class UI.Event.

 

Cheers!

 

Tom Hawker

Senior Framework Developer

Home

+1 (408) 274-4128

The Environment:

We take it personally

Office

+1 (408) 576-6591

Mobile

+1 (408) 835-3643

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of reinier van oosten
Sent: Tuesday, March 10, 2009 2:52 PM
To: [hidden email]
Subject: [vwnc] Code compiled in the wrong namespace

 

Dear list,

 

I am working on code generation. In this work I found a compilation problem. 

 

I try to compile conditionally a class in a namespace. If there is no class of that name in an imported namespace, there is no problem. However in the next case the class did not compile.

 

Generated code:

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it package="Lb-domain">LbTest ifNil:[ Smalltalk defineNameSpace: 'LbTest' private: false
        imports: 'private Smalltalk.* private XML.* private GIPA.* ' category: 'Lb-domain'
        attributes: #( #(#package 'Lb-domain'))]</do-it>
    <do-it package="Lb-domain">Smalltalk at: 'LbTest.Event' ifAbsent: [LbTest defineClass: #Event
        superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ' '
        classInstanceVariableNames: ' ' imports: ' ' category: 'Lb-domain' attributes: #(#(#package
        'Lb-domain'))]</do-it>
</st-source>

 

First I define, if necessary, the namespace LbTest. Then I create the class LbTest.Event. 

The result in the changes file shows that the namespace is created, however the class is not. I also created a class LbTest.Meet, which was created.

 

The following piece of code and the way the system is reacting on it is more disturbing.

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it
package="Lb-domain">LbTest.Event addInstVarName: 'daytime'</do-it>
    <methods>
        <class-id>LbTest.Event</class-id>
        <category>attribute-accessing</category>
        <body
package="Lb-domain" selector="daytime:">
daytime: anObject
    "This is generated code from GIPA for attribute daytime
    GIPA is developed by Reinier van Oosten [hidden email] "
   
    | theObject |
    theObject := anObject.
    (theObject isKindOf: Core.Time) ifFalse:[self error: 'Wrong type for attribute daytime'].
    daytime := theObject</body>
    <body
package="Lb-domain" selector="daytime">
daytime
    "This is generated code from GIPA for attribute daytime
    GIPA is developed by Reinier van Oosten [hidden email] "
    ^daytime</body>
    </methods>
</st-source>

 

I add the variable daytime to the class LbTest.Event and add some methods to that class. The log from the changes are very informative however unexpected.

I show here the entries in the changeList tool

 

Smalltalk.UI defineClass: #Event

            superclass: #{Core.Object}

            indexedType: #none

            private: false

            instanceVariableNames: 'time initiator window daytime '

            classInstanceVariableNames: ''

            imports: ''

            category: 'Interface-Events'

            attributes: #(

                                    #(#package 'Interface-Events'))

 

daytime: anObject

            "This is generated code from GIPA for attribute daytime

            GIPA is developed by Reinier van Oosten

            [hidden email]

                        "

            | theObject |

            theObject := anObject.

            (theObject isKindOf: Core.Time) 

                        ifFalse:[self error: 'Wrong type for attribute daytime'].

            daytime := theObject

 

daytime

            "This is generated code from GIPA for attribute daytime

            GIPA is developed by Reinier van Oosten

            [hidden email]

                        "

            ^daytime

 

Apparently the system finds the class Smalltalk.UI.Event, and instead of creating a new class LbTest.Event it works with UI.Event.

This is not expected and for sure not something you want.

 

Reinier van Oosten

Pelschans 7

2728 GV  Zoetermeer

 

tel: 079-3437073

gsm: 0651335993

 

 

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Code compiled in the wrong namespace

reinier van oosten-2
Hello Thomas,

Thank you for your response. I tried it, but it didn't work. The result is the same as before. 

I think the crux is that in namespace LbTest the class Event is imported. I will try whether the namespace of the found class is actually LbTest.
Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

tel: 079-3437073
gsm: 0651335993



On 10 Mar 2009, at 23:06, <[hidden email]> wrote:

Reinier,

 

I think your class creation do-it is incorrect.  You start with the test:

 

Smalltalk at: ‘LbTest.Event’ ifAbsent: […]

 

Smalltalk won’t find the string ‘LbTest.Event’ – that is, as a name space, Smalltalk only has keys of symbols, and they are completely unqualified.  Thus, the name space UI, under Smalltalk, exists with key #OS, etc.

 

What I think you want is a test like this instead:

 

#{LbTest.Event} isDefined ifFalse: […]

 

You want to resolve the name #Event in the context of its namespace, #LbTest, so you have to use a qualified reference.  Otherwise, as it did, it will resolve the name #Event to class UI.Event.

 

Cheers!

 

Tom Hawker
<image001.gif>
Senior Framework Developer
Home
+1 (408) 274-4128
<image002.gif>The Environment:
We take it personally
Office
+1 (408) 576-6591
Mobile
+1 (408) 835-3643

 


From: [hidden email] [[hidden email]] On Behalf Of reinier van oosten
Sent: Tuesday, March 10, 2009 2:52 PM
To: [hidden email]
Subject: [vwnc] Code compiled in the wrong namespace

 

Dear list,

 

I am working on code generation. In this work I found a compilation problem. 

 

I try to compile conditionally a class in a namespace. If there is no class of that name in an imported namespace, there is no problem. However in the next case the class did not compile.

 

Generated code:

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it package="Lb-domain">LbTest ifNil:[ Smalltalk defineNameSpace: 'LbTest' private: false
        imports: 'private Smalltalk.* private XML.* private GIPA.* ' category: 'Lb-domain'
        attributes: #( #(#package 'Lb-domain'))]</do-it>
    <do-it package="Lb-domain">Smalltalk at: 'LbTest.Event' ifAbsent: [LbTest defineClass: #Event
        superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ' '
        classInstanceVariableNames: ' ' imports: ' ' category: 'Lb-domain' attributes: #(#(#package
        'Lb-domain'))]</do-it>
</st-source>

 

First I define, if necessary, the namespace LbTest. Then I create the class LbTest.Event. 
The result in the changes file shows that the namespace is created, however the class is not. I also created a class LbTest.Meet, which was created.

 

The following piece of code and the way the system is reacting on it is more disturbing.

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it
 package="Lb-domain">LbTest.Event addInstVarName: 'daytime'</do-it>
    <methods>
        <class-id>LbTest.Event</class-id>
        <category>attribute-accessing</category>
        <body
 package="Lb-domain" selector="daytime:">
daytime: anObject 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] " 
    
    | theObject | 
    theObject := anObject. 
    (theObject isKindOf: Core.Time) ifFalse:[self error: 'Wrong type for attribute daytime']. 
    daytime := theObject</body>
    <body
 package="Lb-domain" selector="daytime">
daytime 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] "
    ^daytime</body>
    </methods>
</st-source>

 

I add the variable daytime to the class LbTest.Event and add some methods to that class. The log from the changes are very informative however unexpected.
I show here the entries in the changeList tool

 

Smalltalk.UI defineClass: #Event
            superclass: #{Core.Object}
            indexedType: #none
            private: false
            instanceVariableNames: 'time initiator window daytime '
            classInstanceVariableNames: ''
            imports: ''
            category: 'Interface-Events'
            attributes: #(
                                    #(#package 'Interface-Events'))

 

daytime: anObject
            "This is generated code from GIPA for attribute daytime
            GIPA is developed by Reinier van Oosten
            [hidden email]
                        "
            | theObject |
            theObject := anObject.
            (theObject isKindOf: Core.Time) 
                        ifFalse:[self error: 'Wrong type for attribute daytime'].
            daytime := theObject

 

daytime
            "This is generated code from GIPA for attribute daytime
            GIPA is developed by Reinier van Oosten
            [hidden email]
                        "
            ^daytime

 

Apparently the system finds the class Smalltalk.UI.Event, and instead of creating a new class LbTest.Event it works with UI.Event.
This is not expected and for sure not something you want.

 

Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

 

tel: 079-3437073
gsm: 0651335993

 

 

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Code compiled in the wrong namespace

thomas.hawker
In reply to this post by thomas.hawker

Reinier,

 

Actually, you could change the test to:

 

(LbTest localBindingFor: #Event) isNil ifTrue: […]

 

That check won’t look at imported definitions.

 

Then again, maybe you shouldn’t use the class name #Event just to avoid the ambiguity.

 

Cheers!

 

Tom Hawker

Senior Framework Developer

Home

+1 (408) 274-4128

The Environment:

We take it personally

Office

+1 (408) 576-6591

Mobile

+1 (408) 835-3643

 


From: reinier van oosten [mailto:[hidden email]]
Sent: Tuesday, March 10, 2009 4:04 PM
To: THOMAS HAWKER (IRIS2-ISD-OOCLL/SNT)
Subject: Re: [vwnc] Code compiled in the wrong namespace

 

Hello Thomas,

 

Thank you for your response. I tried it, but it didn't work. The result is the same as before. 

 

I think the crux is that in namespace LbTest the class Event is imported. I will try whether the namespace of the found class is actually LbTest.

Reinier van Oosten

Pelschans 7

2728 GV  Zoetermeer

 

tel: 079-3437073

gsm: 0651335993

 



 

On 10 Mar 2009, at 23:06, <[hidden email]> wrote:



Reinier,

 

I think your class creation do-it is incorrect.  You start with the test:

 

Smalltalk at: ‘LbTest.Event’ ifAbsent: […]

 

Smalltalk won’t find the string ‘LbTest.Event’ – that is, as a name space, Smalltalk only has keys of symbols, and they are completely unqualified.  Thus, the name space UI, under Smalltalk, exists with key #OS, etc.

 

What I think you want is a test like this instead:

 

#{LbTest.Event} isDefined ifFalse: […]

 

You want to resolve the name #Event in the context of its namespace, #LbTest, so you have to use a qualified reference.  Otherwise, as it did, it will resolve the name #Event to class UI.Event.

 

Cheers!

 

Tom Hawker

<image001.gif>

Senior Framework Developer

Home

+1 (408) 274-4128

<image002.gif>The Environment:

We take it personally

Office

+1 (408) 576-6591

Mobile

+1 (408) 835-3643

 


From: [hidden email] [[hidden email]] On Behalf Of reinier van oosten
Sent: Tuesday, March 10, 2009 2:52 PM
To: [hidden email]
Subject: [vwnc] Code compiled in the wrong namespace

 

Dear list,

 

I am working on code generation. In this work I found a compilation problem. 

 

I try to compile conditionally a class in a namespace. If there is no class of that name in an imported namespace, there is no problem. However in the next case the class did not compile.

 

Generated code:

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    
<time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 
</time-stamp>
    
<do-it package="Lb-domain">LbTest ifNil:[ Smalltalk defineNameSpace: 'LbTest' private: false
        imports: 'private Smalltalk.* private XML.* private GIPA.* ' category: 'Lb-domain'
        attributes: #( #(#package 'Lb-domain'))]
</do-it>
    
<do-it package="Lb-domain">Smalltalk at: 'LbTest.Event' ifAbsent: [LbTest defineClass: #Event
        superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ' '
        classInstanceVariableNames: ' ' imports: ' ' category: 'Lb-domain' attributes: #(#(#package
        'Lb-domain'))]
</do-it>
</st-source>

 

First I define, if necessary, the namespace LbTest. Then I create the class LbTest.Event. 

The result in the changes file shows that the namespace is created, however the class is not. I also created a class LbTest.Meet, which was created.

 

The following piece of code and the way the system is reacting on it is more disturbing.

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it
 package="Lb-domain">LbTest.Event addInstVarName: 'daytime'</do-it>
    <methods>
        <class-id>LbTest.Event</class-id>
        <category>attribute-accessing</category>
        <body
 package="Lb-domain" selector="daytime:">
daytime: anObject 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] " 
    
    | theObject | 
    theObject := anObject. 
    (theObject isKindOf: Core.Time) ifFalse:[self error: 'Wrong type for attribute daytime']. 
    daytime := theObject</body>
    <body
 package="Lb-domain" selector="daytime">
daytime 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] "
    ^daytime</body>
    </methods>
</st-source>

 

I add the variable daytime to the class LbTest.Event and add some methods to that class. The log from the changes are very informative however unexpected.

I show here the entries in the changeList tool

 

Smalltalk.UI defineClass: #Event

            superclass: #{Core.Object}

            indexedType: #none

            private: false

            instanceVariableNames: 'time initiator window daytime '

            classInstanceVariableNames: ''

            imports: ''

            category: 'Interface-Events'

            attributes: #(

                                    #(#package 'Interface-Events'))

 

daytime: anObject

            "This is generated code from GIPA for attribute daytime

            GIPA is developed by Reinier van Oosten

            [hidden email]

                        "

            | theObject |

            theObject := anObject.

            (theObject isKindOf: Core.Time) 

                        ifFalse:[self error: 'Wrong type for attribute daytime'].

            daytime := theObject

 

daytime

            "This is generated code from GIPA for attribute daytime

            GIPA is developed by Reinier van Oosten

            [hidden email]

                        "

            ^daytime

 

Apparently the system finds the class Smalltalk.UI.Event, and instead of creating a new class LbTest.Event it works with UI.Event.

This is not expected and for sure not something you want.

 

Reinier van Oosten

Pelschans 7

2728 GV  Zoetermeer

 

tel: 079-3437073

gsm: 0651335993

email: [hidden email]

 

 

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Code compiled in the wrong namespace

reinier van oosten-2
Hello Thomas,

I tried it in two ways: 

Smalltalk at: 'LbTest.Event' ifAbsent: [].
        targetClass ifNotNil: [targetClass environment fullName = 'LbTest' ifFalse:[targetClass := nil]].
        targetClass ifNil:[....]

and 

(LbTest localBindingFor: #Event) ifNil: [...]

Both worked. I prefer your solution. Thank you for sharing your ideas.

I agree with you that you shouldn't use the class name #Event. But this is the result of code generation under development. In the end this should lead to a publishable parcel. Others may not be as prudent. In this respect I'm happy to have stumbled in this problem.

Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

tel: 079-3437073
gsm: 0651335993



On 11 Mar 2009, at 00:08, <[hidden email]> wrote:

Reinier,

 

Actually, you could change the test to:

 

(LbTest localBindingFor: #Event) isNil ifTrue: […]

 

That check won’t look at imported definitions.

 

Then again, maybe you shouldn’t use the class name #Event just to avoid the ambiguity.

 

Cheers!

 

Tom Hawker
<image001.gif>
Senior Framework Developer
Home
+1 (408) 274-4128
<image002.gif>The Environment:
We take it personally
Office
+1 (408) 576-6591
Mobile
+1 (408) 835-3643

 


From: reinier van oosten [[hidden email]] 
Sent: Tuesday, March 10, 2009 4:04 PM
To: THOMAS HAWKER (IRIS2-ISD-OOCLL/SNT)
Subject: Re: [vwnc] Code compiled in the wrong namespace

 

Hello Thomas,

 

Thank you for your response. I tried it, but it didn't work. The result is the same as before. 

 

I think the crux is that in namespace LbTest the class Event is imported. I will try whether the namespace of the found class is actually LbTest.
Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

 

tel: 079-3437073
gsm: 0651335993

 



 

On 10 Mar 2009, at 23:06, <[hidden email]> wrote:


Reinier,

 

I think your class creation do-it is incorrect.  You start with the test:

 

Smalltalk at: ‘LbTest.Event’ ifAbsent: […]

 

Smalltalk won’t find the string ‘LbTest.Event’ – that is, as a name space, Smalltalk only has keys of symbols, and they are completely unqualified.  Thus, the name space UI, under Smalltalk, exists with key #OS, etc.

 

What I think you want is a test like this instead:

 

#{LbTest.Event} isDefined ifFalse: […]

 

You want to resolve the name #Event in the context of its namespace, #LbTest, so you have to use a qualified reference.  Otherwise, as it did, it will resolve the name #Event to class UI.Event.

 

Cheers!

 

Tom Hawker
<image001.gif>
Senior Framework Developer
Home
+1 (408) 274-4128
<image002.gif>The Environment:
We take it personally
Office
+1 (408) 576-6591
Mobile
+1 (408) 835-3643

 


From: [hidden email] [[hidden email]] On Behalf Of reinier van oosten
Sent: Tuesday, March 10, 2009 2:52 PM
To: [hidden email]
Subject: [vwnc] Code compiled in the wrong namespace

 

Dear list,

 

I am working on code generation. In this work I found a compilation problem. 

 

I try to compile conditionally a class in a namespace. If there is no class of that name in an imported namespace, there is no problem. However in the next case the class did not compile.

 

Generated code:

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    
<time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 
</time-stamp>
    
<do-it package="Lb-domain">LbTest ifNil:[ Smalltalk defineNameSpace: 'LbTest' private: false
        imports: 'private Smalltalk.* private XML.* private GIPA.* ' category: 'Lb-domain'
        attributes: #( #(#package 'Lb-domain'))]
</do-it>
    
<do-it package="Lb-domain">Smalltalk at: 'LbTest.Event' ifAbsent: [LbTest defineClass: #Event
        superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ' '
        classInstanceVariableNames: ' ' imports: ' ' category: 'Lb-domain' attributes: #(#(#package
        'Lb-domain'))]
</do-it>
</st-source>

 

First I define, if necessary, the namespace LbTest. Then I create the class LbTest.Event. 
The result in the changes file shows that the namespace is created, however the class is not. I also created a class LbTest.Meet, which was created.

 

The following piece of code and the way the system is reacting on it is more disturbing.

 

<?xml version="1.0" encoding="UTF-8"?>
<st-source>
    <time-stamp> This is generated code from GIPA (Generator of Integrity Preserving Associations)
        GIPA is developed by Reinier van Oosten 2009 [hidden email] March 10, 2009
        22:03:25.327 </time-stamp>
    <do-it
 package="Lb-domain">LbTest.Event addInstVarName: 'daytime'</do-it>
    <methods>
        <class-id>LbTest.Event</class-id>
        <category>attribute-accessing</category>
        <body
 package="Lb-domain" selector="daytime:">
daytime: anObject 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] " 
    
    | theObject | 
    theObject := anObject. 
    (theObject isKindOf: Core.Time) ifFalse:[self error: 'Wrong type for attribute daytime']. 
    daytime := theObject</body>
    <body
 package="Lb-domain" selector="daytime">
daytime 
    "This is generated code from GIPA for attribute daytime 
    GIPA is developed by Reinier van Oosten [hidden email] "
    ^daytime</body>
    </methods>
</st-source>

 

I add the variable daytime to the class LbTest.Event and add some methods to that class. The log from the changes are very informative however unexpected.
I show here the entries in the changeList tool

 

Smalltalk.UI defineClass: #Event
            superclass: #{Core.Object}
            indexedType: #none
            private: false
            instanceVariableNames: 'time initiator window daytime '
            classInstanceVariableNames: ''
            imports: ''
            category: 'Interface-Events'
            attributes: #(
                                    #(#package 'Interface-Events'))

 

daytime: anObject
            "This is generated code from GIPA for attribute daytime
            GIPA is developed by Reinier van Oosten
            [hidden email]
                        "
            | theObject |
            theObject := anObject.
            (theObject isKindOf: Core.Time) 
                        ifFalse:[self error: 'Wrong type for attribute daytime'].
            daytime := theObject

 

daytime
            "This is generated code from GIPA for attribute daytime
            GIPA is developed by Reinier van Oosten
            [hidden email]
                        "
            ^daytime

 

Apparently the system finds the class Smalltalk.UI.Event, and instead of creating a new class LbTest.Event it works with UI.Event.
This is not expected and for sure not something you want.

 

Reinier van Oosten
Pelschans 7
2728 GV  Zoetermeer

 

tel: 079-3437073
gsm: 0651335993

 

 

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.

 

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not intended for you, please delete it immediately unread.  The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in doing so.  Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email.  Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc