🎉 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!

Tangent: Smash Syntax! (part 1)

Published February 11, 2009
Advertisement
Before we get to coding work, news and opinions. My workplace laid off a small percentage of its workforce. Mostly the most expensive workforce (definitely not me!). Unfortunately that tends to be the most skilled of the workforce. How a company can continue to survive such clearly braindead executive decisions is mildly baffling.

The kindle2 came out recently, and looks kinda nifty. I looked at the first one, but was scared off by the price mostly. I don't really want a kindle. I want an iPhone the size of the kindle. Who cares if I can't put it to my ear to hold a conversation? The only time I'd use it as a phone is to order pizza...


Now to work. I planned out phrase re-implementation earlier in the week. A good 150 lines of comments; mostly with process description, a little psuedo code. Tonight I went through and broke almost all of the language with a breaking change to the syntax. The position of the return type is being shifted from C style to functional style:

public static void main(){...}// TOpublic static main()=>void {...}


Despite all evidence to the contrary, I am not an ApochPiQ wannabe (even though he's doing great work, and you should go look). No, it's been something I've been considering for a while. There are 3 or so reasons off the top of my head.

1. Eventually I'd like to support type expressions. It gets a lot harder to unambiguously determine the return type when it's not a simple identifier. The explicit => aids that.

2. This causes the syntax to be very similar to the lambda syntax. Some unification there might allow for decreased code duplication and a better system overall.

3. This will allow more parameter flexibility. Operators for example will be able to done in order.

// Pre-changepublic static operator int    plus(int lhs, int rhs){...}// Post-changepublic static operator   (int lhs) + (int rhs) => int {...}


It also means the 'operator' keyword is extraneous. If the first argument is an identifier or symbol, it's a simple phrase. If it's the second, then a binary operator with that as the name/hook. I'm leaving that keyword in to be explicit, but am looking for feedback (hint.) if it's necessary still.

Now it's time to add the symbols as allowable syntax and then phrase reimplementation. Until then, nothing beyond unary operations work...
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement