Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

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

Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-1.4 Difficulty-Easy

New issue 5142 by [hidden email]: Color depends on Compiler while it  
could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

The class Color is clever and compile accessor for classVar accesses on the  
fly.

For example

black
    ^ Black

was defined using the following method.

named: newName put: aColor
        "Add a new color to the list and create an access message and a class  
variable for it.  The name should start with a lowercase letter.  (The  
class variable will start with an uppercase letter.)  (Color colorNames)  
returns a list of all color names.  "
        | str cap sym accessor csym |
        str := newName asString.
        sym := str asSymbol.
        cap := str capitalized.
        csym := cap asSymbol.
        (self class canUnderstand: sym) ifFalse:
                [ "define access message"
                accessor := str , (String
                                with: Character cr
                                with: Character tab) , '^' , cap.
                self class
                        compile: accessor
                        classified: 'named colors' ].
        (self classPool includesKey: csym) ifFalse: [ self addClassVarNamed: cap ].
        (ColorNames includes: sym) ifFalse: [ ColorNames add: sym ].
        ^ self classPool
                at: csym
                put: aColor


While this is cool and probably fun to do. It links the Color class to the  
compiler.
We should define by hand a nice initialization (quite stupid) and stop  
relying on code generation.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Updates:
        Status: FixReviewNeeded

Comment #1 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

It's also inconsistent, it has colors initialized and referenced by Class  
vars like:

(a)
orange
        ^Orange

and other just convenience methods like:

(b)
paleBlue
        ^(Color r: 0.87 g: 0.976 b: 0.995)


What about writing all well known colors in the second form (b) and remove  
the #named:put: method?

Of course, this version does not cache the colors, but it can be done using  
a variablePool or a dictionary

I attach a changeset

Attachments:
        colors.2.cs  5.9 KB


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
In reply to this post by pharo
Updates:
        Labels: Type-Cleanup

Comment #3 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Updates:
        Labels: -Milestone-1.4

Comment #4 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

Not a show stopper for 1.4


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo

Comment #5 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

named: newName put: aColor
        "Add a new color to the list and create an access message and a class  
variable for it.  The name should start with a lowercase letter.  (The  
class variable will start with an uppercase letter.)  (Color colorNames)  
returns a list of all color names.  "
        | str cap sym accessor csym |
        str := newName asString.
        sym := str asSymbol.
        cap := str capitalized.
        csym := cap asSymbol.
        (self classPool includesKey: csym) ifFalse: [ self addClassVarNamed: cap ].
        (ColorNames includes: sym) ifFalse: [ ColorNames add: sym ].
        ^ self classPool
                at: csym
                put: aColor



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo

Comment #6 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

(No comment was entered for this change.)

Attachments:
        Color class-namedput.st  772 bytes


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Updates:
        Status: FixToInclude
        Labels: 1.4

Comment #7 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo

Comment #8 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

Marcus this change is ready and much simpler than the change proposed by  
guillermo.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Updates:
        Labels: -1.4 Milestone-1.4

Comment #9 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo
Updates:
        Status: Integrated

Comment #10 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

in 14413


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5142 in pharo: Color depends on Compiler while it could just declare colors

pharo

Comment #11 on issue 5142 by [hidden email]: Color depends on  
Compiler while it could just declare colors
http://code.google.com/p/pharo/issues/detail?id=5142

But does it work?

Color named: 'paleAAA' put: Color red.
Color paleAAA


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker