ProyectoFinal2015 / wollok

Wollok Programming Language
0 stars 0 forks source link

Model keyboard keys as WKO's #29

Closed javierfernandes closed 8 years ago

javierfernandes commented 8 years ago

I think we can avoid modeling keys as "strings" by using well-known objects.

Instead of this

    keys.onPress("M").do [ granjero.plantaMaiz() ]
    keys.onPress("T").do [ granjero.plantaTrigo() ]
    keys.onPress("O").do [ granjero.plantaTomaco() ]
    keys.onPress("R").do [ granjero.rega() ]
    keys.onPress("C").do [ granjero.cosechaTodo() ]

Model it as

import wollok.game.keyboard.*

    keys.onPress(M).do [ granjero.plantaMaiz() ]
    keys.onPress(T).do [ granjero.plantaTrigo() ]
    keys.onPress(O).do [ granjero.plantaTomaco() ]
    keys.onPress(R).do [ granjero.rega() ]
    keys.onPress(C).do [ granjero.cosechaTodo() ]

Which has the advantages of compile-time checks.

What do you think ?

PalumboN commented 8 years ago

Like! :+1:

javierfernandes commented 8 years ago

I think i'll move this issues to the main repo and creat a label for wgame El dic 12, 2015 1:43 AM, "Nahuel Palumbo" notifications@github.com escribió:

Reopened #29 https://github.com/ProyectoFinal2015/wollok/issues/29.

— Reply to this email directly or view it on GitHub https://github.com/ProyectoFinal2015/wollok/issues/29#event-490002177.

PalumboN commented 8 years ago

Ok, perfect!

PalumboN commented 8 years ago

I was thinking, if we have each key model as an object so we can do something like:

import wollok.game.keyboard.*

    M.onPressDo [ granjero.plantaMaiz() ]
    T.onPressDo [ granjero.plantaTrigo() ]
    O.onPressDo [ granjero.plantaTomaco() ]
    R.onPressDo [ granjero.rega() ]
    C.onPressDo [ granjero.cosechaTodo() ]

And we don't need the keys object.

What do you think?

javierfernandes commented 8 years ago

Cool !

Created a new issue in wollok with a summarized version

https://github.com/uqbar-project/wollok/issues/477