🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Make yourself famous!

Published March 11, 2009
Advertisement
I've been toying around with various syntax options for the message passing model. So far I'm not terribly happy with any of them, but I have settled on one of the lesser evils. I'd like to just kick this out and see if anyone has some thoughts on how to improve it.

Unfortunately I can't afford to let this sit around for a few days collecting ideas, since I have such time pressure to get it all implemented and running. However, if some good suggestions arise, I'll definitely do what I can to change the syntax. For now, though, this is what message passing will look like:

entrypoint : () -> (){	task(async)	{		integer(my_foo, 0)		dispatch initialize : integer(foo)) => { assign(my_foo, foo) }				wait(initialize)		message(master, result(add(my_foo, 42)))	}	dispatch result : (integer(foo)) => { debugwritestring(cast(string, foo)) }	message(async, initialize(4))	wait(result)}



2100 Hours
Erugh. The more I look at that code, the worse it sucks.

The first thing that came out of my twisted head looks like this:
entrypoint : () -> (){	task(async)	{		integer(my_foo, 0)		onmessage(initialize(integer(foo)))		{			assign(my_foo, foo);		}				wait(initialize)		message(master, result(add(my_foo, 42)))	}	message(async, initialize(4))	onmessage(result(integer(foo)))	{		debugwritestring(cast(string, foo))	}	wait(result)}



Slightly more readable but still disgusting.

It looks like I may have to violate my own principles and include some new symbols, because this function-style mess is getting ridiculous for complex tasks.

Will post further updates as I come up with (hopefully) better alternatives.


Ten minutes later...

Here's another attempt:

message sendint :(	integer(foo))entrypoint : () -> (){	task(async)	{		integer(my_foo, 0)		onmsg(sendint) { assign(my_foo, foo) }		wait()		master(sendint, my_foo)			}	async(sendint, 4)	onmsg(sendint) { debugwritestring(cast(string, result)) }	wait()}


On the plus side, I find it nice and compact and pretty readable. On the down side, it's still kind of hard to see how the flow of messages and data works. Also, having to pre-declare messages kind of sucks.

2125 Hours
Another alternative, mainly just a slight tweaking to get the syntax more "Epoch-like":

entrypoint : () -> (){	task(async)	{		integer(my_foo, 0)		onmsg sendint : (integer(foo))		{ assign(my_foo, foo) }		wait()		mastertask(sendint(add(my_foo, 42)))	}	async(sendint(99))	onmsg sendint : (integer(foo))	{ debugwritestring(cast(string, result)) }	wait()}


Still not really happy with it, but it's better than the other options, at least IMHO.
0 likes 2 comments

Comments

Telastyn
It took me like 4 readings to figure out what goes where. What are the scoping rules for the dispatches?
March 11, 2009 06:22 PM
Telastyn
It took me like 5 readings to get the first version. Perhaps it's because of no syntax highlighting, perhaps due to unfamiliarity. I don't remember how your structs work, but having the tasks have 'members' that are the named slots seems consistent enough.

I don't think the message invocation is any more awkward than the normal lisp-y syntax.
March 11, 2009 09:14 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement