lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Nov 12, 2009, at 4:01 AM, David Given wrote:

> And personally, I think the syntax is appallingly ugly:
> func (p *ByteSlice) Write(data []byte) (n int, err os.Error)
> ...defines a method on 'pointer to ByteSlice' (you can define methods on
> pretty much any type, not just objects) with self called 'p', taking an
> array of bytes called 'data' as parameter, returning a tuple of int and
> os.Error.

I think I see where this is going in that it seems to adopt the C notion of making declarations look like usage, but putting the type name afterward. It seems like a mix of C and Wirthian conventions. On the other hand, it's probably better formatted as:

	func( p* ByteSlice ) Write( data[] byte )( n int, err os.Error )

Still that's an awful lot to get out of positional notation. Oberon-2 used the same sort of declaration for self and it didn't bother me so I think it's the result type that seems to push things too far for me.

	func ( p* ByteSlice ) Write( data[] byte ) : ( n int, err os.Error )

Starts to look a bit better. But the Oberon-2 version would probably be more like:

	FUNCTION ( p: ByteSlicePtr ) Write ( data: ByteArray ) : ( n: INTEGER; err: OS.Error )

I'm still finding Write to feel lost in that notation, however.

I haven't read the Go spec yet, but when I gathered it was going for essentially low-level but safe semantics, I have to say I immediately thought about Oberon which I've always viewed as Wirth's evolution toward C.