[xinf] Events counter-proposal
daniel fischer
dan at f3c.com
Sun Jul 9 16:32:29 CEST 2006
"hank williams" <hank777 at gmail.com> (on Sun, 9 Jul 2006 10:05:49 -0400):
> > > 2. did you really mean this:
> > >
> > > class MouseEvent extends Event<MouseEvent> {
> >
> > yes- this comes directly from Nicolas' hint. I admit its weird. It's
> > not recursive really (the Test.hx compiles and runs fine), it "just"
> > tells the parent Event<T> class to use the child class (MouseEvent) as
> > type parameter. I dont know how to explain this well, but it's a key
> > element in the typesafety of this proposal. It constrains the "type"
> > property of the Event<T> base class to types of class
> > EventType<MouseEvent>.
>
> I really would love a deeper explanation of this when nicolas gets back.
these things are sometimes hard to wrap your head around. in case you're familiar with C++ templates, it probably gets a little more obvious. I'll try again, tho:
The Event<T> class is typed to a specific subclass of itself. "MouseEvent extends Event<MouseEvent>" assures that you cannot create a MouseEvent with a type other than EventType<MouseEvent>. This way, Events are coupled to specific EventTypes and EventTypes to specific Event classes. It's weird, but only in a sense that it's a programming construct we're not so used to. I think this would be legal in C++, too.
Was this any better? I doubt it.
> I am not as concerned about type safety as I am about "semantic safety". In
> events, just because you are type safe doesnt mean you are safe. If you name
> something the same thing in two places but the *mean* different things, even
> if the types are the same, you are screwed in a way that would be *very*
> difficult to figure out.
Hm. I'm interested in how you would describe that semantic meaning. I mean, mouseDown means "a mouse button has been pressed while the mouse cursor was above the target". Is that the kind of semantics you mean? You're probably thinking about other kinds of events-- could you give an example? How can you *possibly* assure "semantic safety" there, without resorting to DAML/OIL and the likes? Or is that what you have in mind? But wouldn't it include having to describe the complete semantic functioning of your application - an impossible task?
To me, what an event means is implicitly defined by its name- and associated documentation. The EventTypes thing allows us to describe an event in the API docs. The EventType (and its name) "link" to this meaning.
I know you've written a lot about this, but i still dont seem to get it. Can you provide an ad-hoc example of a semantic event description in XML (or whatever)?
> By the way, this is why I
> also suggest a production and debug version of the dispatcher. The debug
> version would allow you to track all, or just specific events and to see who
> is subscribed and where things go. I do this in my code and it is invaluable
> to debugging this kind of code.
I like that idea. Maybe we could add a PosInfos object to postEvent, and carry that around in the debugging version as to provide a hint where the event originated? Would that be enough?
> > does anyone know when our prophet will return from his pilgrimage (or
> > wherever he went)?
>
> I dont know about this prophet thing. Someone else on the haXe list refered
> to him a Jesus. Things are getting out of hand here. If we cant get his head
> through any doors he wont be of much use to us! lol :)
i wasn't too serious :). Nicolas is probably a genius, but you should never get too religious about programming languages (or operating systems) ;)
Also- i dont see the problem with his head.. We can always get him a laptop, wireless and some pizzas to wherever he's stuck :)
> Anyway, he just seemed to disappear. I dont recollect any announcements
> about leaving for vacation or anything, but I would imagine thats what he
> did. Hopefully back soon.
of course. but also, absence of the "project leader" can be very healthy for some projects- people start to think for themselves :) I saw that happening with swfmill.
-dan
--
http://0xDF.com/
http://iterative.org/
More information about the xinf
mailing list