Skip to content

Instantly share code, notes, and snippets.

@PhilipWitte
Last active August 29, 2015 13:56
Show Gist options
  • Save PhilipWitte/9314927 to your computer and use it in GitHub Desktop.
Save PhilipWitte/9314927 to your computer and use it in GitHub Desktop.
# Change set's to @{} instead of {}
# which is consistent with seq
var mySet = @{ A, B, C }
var mySeq = @[ a, b, c ]
# Force ':' where ever a "body" is consumed which
# allows both indent style and bracket-style
# the follow types are all identical..
type Foo* {.final.} = ref object:
a: int
b: float
type Foo* {.final.} = ref object [
a: int,
b: float
]
type Foo* {.final.} = ref object {
a: int
b: float
}
# Move proc pragmas to the left, and use '=' for where ':'
# currently is, which makes it's meaning consistent with type declares
# the following procs are the same...
proc bar*(f:Foo) {.noSideEffect.} = float:
if f.isNil: 0
else: f.a + f.b
proc bar*(f:Foo) {.noSideEffect.} = float {
if f.isNil: 0
else: f.a + f.b
}
# Shorthands..
type Foo:
a, b: int
proc bar:
echo ".."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment