Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Oct 2003
Offline Last Active Sep 12 2011 12:16 PM

Topics I've Started

Your ideal syntax

15 February 2010 - 06:25 PM

So I'm making a programming language and I'd like it to have a really nice and readable syntax. But I can't decide on some things. First off, what do you think would be an ideal syntax for a language that is primarily used for coding games? Second, take a look at what I have and tell me if you think it sucks.
-- Comments start with two dashes

-- Function calls look like this
function(arg0, arg1)

-- Instead of declaring variables, you attach names to expressions
a = function(arg0, arg1)

-- There's infix operators
a = 1 - 2

-- Blocks start with keywords and end with 'end' (like Ruby)
if something

-- But I can't decide if blocks should have significant indentation like Python. What do you think?
if something:

-- Or possibly curly brackets
if something {

-- This is a function definition.
-- The language is statically typed, so each argument has a type name.
def my_func(int a, int b)

-- This is a function that returns something, the return type is declared with ->
def my_func(int a, int b) -> int
  return a - b

-- But maybe the 'return' should be optional, and the function should just return the last expression?
def my_func(int a, int b) -> int
  a - b

-- Also there are different possible ways to specify the return type
def my_func(int a, int b) { a - b }  -- implicit return type
def my_func(int a, int b) :: Int { return a - b } -- two colons like Haskell
int my_func(int a, int b) { return a - b }  -- return type name in front, C style

-- Here's a real function which draws a filled rectangle
-- The 'gl' part at the beginning of gl:triangles is a namespace
-- The square brackets indicate a list
def fill_rect(Rect rect, Color color)
    "Draw a filled rectangle."
    nw = [rect.x1 rect.y1]
    ne = [rect.x2 rect.y1]
    sw = [rect.x1 rect.y2]
    se = [rect.x2 rect.y2]
    gl:triangles([nw ne se se sw nw] color)

-- The -> operator is used to feed the input on the left to the function on the right.
-- It's there so that the writer can list the sequence of calls in left-to-right order
-- instead of right-to-left.
some_function() -> print
-- is the same as:

-- The @ operator is shorthand that takes a name, and rebinds the overall result to
-- that name. It's there to make it easier to write a chain of expressions that
-- all operate on a certain name. Does this suck?
add(@a, 2)
-- is the same as:
a = add(a, 2)

This post is getting long so I'll stop there. TIA for feedback.

Language design: dashes in identifiers

02 April 2009 - 05:27 AM

Like many people, I'm writing a programming language. But I have a problem that has me stumped. I like how Lisp allows dashes in identifiers. So, I accept code that looks like this:

my-variable = a-function(5.0, something-else) / 2.0

I think dashes make things more readable and allow for more expressiveness. The problem is, I also accept infix expressions. So this code is okay:

difference = a - b

but this would be an error:

difference = a-b

because it would look for a variable named "a-b". So programmers would have to learn that they would have to put spaces around the - operator. I can probably also have some kind of compiler-generated warning that looks for this mistake, but there will always be edge cases that it gets wrong. Is this a bad idea or is this a terrible idea? I'd like to make this work somehow, but there's probably a good reason that most languages don't do this..

Good reference on MSVC build & link tools?

04 November 2008 - 08:13 AM

Hi all, I've been having a lot of confusion lately involving the build options in Visual Studio C++. Specifically, building libraries with /MD and /MT, and /NODEFAULTLIB, and etc. Does anyone know of any resource (like a book, or maybe a really good web page) that goes over things like this in excruciating detail? Various questions that I've had lately: Why does my link process barf when one of my libs is built with /MT and one with /MD? Are there any solutions for this (other than rebuilding them with different options)? Is there some connection between building with /MD and distributing the build result as a DLL? The docs seem to suggest that /MD just affects which runtime you use, and has nothing to do with whether you distribute the result as a .lib or .dll . But I keep reading guides & tutorials which seem to suggest there is a connection. How do I properly use /INCREMENTAL ? (All the tutorials I've found are very light on details)

Class naming help

30 May 2008 - 09:42 AM

Sometimes, the hardest part about OO is finding good names. I'm trying to think of a good name for a fairly generic class and I'm wondering if anyone can help. Currently I'm calling it a "ConditionNotifier". But I was also considering getting the word multiplex in there somewhere, like ControlFlowMux or something. It's an object that keeps track of a number of conditions (which are dynamically created), and it triggers some action once they are all satisfied. In more detail, here is what happens: 0) The ConditionNotifier object is initialized with a bunch of conditions. (These are represented as strings, but that's not important) 1) Something tells the ConditionNotifier to start. 2) After some period of time, various things tell the ConditionNotifier that conditions have been met. Don't care about the order. 3) When the last one has been met, the ConditionNotifier triggers all of its listeners, and marks itself as finished. x) Also, at any time, one can ask the ConditionNotifier whether it is currently in progress or if it's finished. y) And, as a later change, I plan on adding a timeout checker, where something can be notified if all then conditions aren't met within 5 (or so) seconds. Fire away!

Gaming in 2010

26 December 2007 - 02:29 PM

This seems to be the time of the year when everybody makes predictions about stuff, so how about we make some predictions for the world of gaming? How will things be different or the same in roughly 2.5 years? I'll kick it off with a few of mine: - Lots of games inspired by Portal. A bunch will be direct knock-offs that use portalling in different ways. And also, there will also be a bunch of games that experiment with completely different forms of mind-bending non-realistic physics. - No new "generation" of consoles. By that I mean, it's not enough anymore to make a console whose sole virtue is that it's more powerful than the consoles that came before it. If any new consoles are developed, their selling point will be new & unique features instead of raw power. Much like the Wii. Along these lines... - Someone will finally make a decent virtual reality / augmented reality console. What are yours?