[Grace-core] Syntax questions

Kim Bruce kim at cs.pomona.edu
Mon Nov 8 17:39:40 PST 2010


My student Eric (copied on this message) is starting to write Grace code, but we have not nailed down some of the specific syntax yet.  Here are some questions and proposed answers:


1. How do we write function types?     S => T  or S -> T
	Proposed answer: S => T  (like Scala)

2.  How do we write anonymous n-ary functions?  (x:S,...) => {...}    or    {(x:S,...) => ...}  
	Proposed answer: (x:S,...) => {...} 
	Default abbreviation:  0-ary functions can be written as () => {...} or in the abbreviated form {...}

3.  Pattern matching notation:  myExp match {case ... => ...; ...}    or    match myExp {case ... => ...; ...}
	No strong feelings.  The first is Scala syntax.

4.  Built-in simple IO:  how do we write simple reads and writes?  We could have a default system I/O object, io, that is visible anywhere and then write output as either:   io.printline(s) or s.printline(io).  Similarly with print, read, readline.
	Are you OK with these names, and which order should we write them?
	Proposed answer: io.printline(s) as that makes it easier to read if we construct complex strings to print.

I'm still concerned about our numeric types.  See comments on the wiki in the Built-In Types section.  However, if we could just clear these questions up rather quickly, then Eric can make some progress.

	Kim


More information about the Grace-core mailing list