Skip to content

Instantly share code, notes, and snippets.

@zah
zah / gist:5598251
Last active December 17, 2015 10:58
Cotire Log
cotire 1.4.0 loaded.
C source file extensions: c
C ignore extensions: h;H;o;O;obj;OBJ;def;DEF;rc;RC
C exclude extensions: m;mm
precompiled.cpp filtered=FALSE language=CXX header=NOTFOUND
main.cpp filtered=FALSE language=CXX header=NOTFOUND
precompiled.h filtered=FALSE language=CXX header=NOTFOUND
All: precompiled.cpp;main.cpp;precompiled.h
C:
Excluded:
# The key thing about the scheme is that stuff gets compiled on first usage
proc foo =
bar()
proc bar =
...
foo() # foo is compiled here (bar is already in scope so it's OK)

@fowlmouth

<zahary_> fowl, sorry, turns out I haven't documented it yet

<zahary_> be warned that we have plans to rename it to static[string]

<zahary_> otherwise it's very simple - when the compiler see a parameter like that, it will try to evaluate statically the passed argument

 proc foo(a: expr[string])
@zah
zah / Messages.nim
Last active December 16, 2015 23:58
Registering messages
there are 3 types of messages
1) statically dispatched to a certain component:
if has(Component): get(Component).doMessage(args)
2) dynamically dispatched to a single component
let (offset, proc_ptr) = entity->typeinfo->vtable[messageID]
proc_ptr(entity->data[offset], args)
3) dynamically dispatched to every component that implements them (multicast messages)
let runlist = entity->typeinfo->multicast_vtable[messageID]
@zah
zah / gist:5487992
Created April 30, 2013 10:53
not breaking you nimrod compiler with nimboot
nimd-build () {
local PREVDIR=`pwd`
cd ~/Projects/nim
nimrod c -d:debug $* compiler/nimrod.nim && cp compiler/nimrod ./bin/nimd
cd $PREVDIR
}
nimd-boot () {
local PREVDIR=`pwd`
cd ~/Projects/nim
var globalFiles: seq[FileInfo]
proc getFileName(i: int): string =
return globalFiles[i].name # unnecessary copy (life-time of the global exceeds any caller score)
type
TFoo = object
data: string
TBar = object
@zah
zah / gist:4096467
Created November 17, 2012 14:43
Async Programming 101
# async procs compatible the framework have a type like:
iterator asyncProc: TPromise[TBlob] =
yield download(url) # download is a function that returns a promise
# there is a loop that works like this:
coroutine = asyncProc()
...
proc stepCoroutine(coro) =
var promise = coro()
promise.onCompleted do:
@zah
zah / gist:4040134
Created November 8, 2012 17:11
vim jump to definition
fun! JumpToDef()
if exists("*GotoDefinition_" . &filetype)
call GotoDefinition_{&filetype}()
else
exe "norm! \<C-]>"
endif
endf
" Jump to tag
nn <M-g> :call JumpToDef()<cr>
@zah
zah / Tupfile
Created September 9, 2012 10:35
: input.txt |> command.bat %f |> %f.out
@zah
zah / Tupfile
Created July 31, 2012 16:46
tup coffee-script project
: test.coffee |> coffee.bat -c %f |> %B.js