Skip to content

Instantly share code, notes, and snippets.

@Araq
Created June 12, 2018 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Araq/9575d2df262d83208092a36ffe06de4b to your computer and use it in GitHub Desktop.
Save Araq/9575d2df262d83208092a36ffe06de4b to your computer and use it in GitHub Desktop.
type
SeqHeader = object
len, reserved: int
proc isLiteral(s: string): bool {.inline.} = (cast[ptr SeqHeader](s).reserved and (1 shl (sizeof(int)*8 - 2))) != 0
proc main(param: string) =
echo "param ", isLiteral(param)
echo "const ", isLiteral("foobar")
main("const here")
var x: string = "foo bar"
main(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment