Skip to content

Instantly share code, notes, and snippets.

View micklat's full-sized avatar

Michael micklat

  • Yeruham, Israel
  • 21:17 (UTC +03:00)
View GitHub Profile
Sharing data without a "shared heap"
This is a proposal for a shared heap without additional GC barriers. It requires some
support from the compiler, in enforcing that only certain kinds of values can be shared
between threads.
* suppose that the nimrod compiler can distinguish between const and non-const pointers
and refs. I think constness can be inferred and need not be declared in most places.
* Define a "rigid" value to be a heap-allocated type V s.t. every pointer reachable from V
@micklat
micklat / funny_cast.nim
Created February 16, 2014 18:53
int not cast to float as expected, instead both values are cast to W
type
W = object
x: float
PW = ref W
converter toW(x: int): PW =
new(result)
result.x = float(x)
converter toW(x: float): PW =

improve the automation of low-level C bindings

Desirable skills: Knowledge of C

Description: Nimrod's c2nim tool helps create nimrod bindings for C libraries. However, c2nim does not parse the whole C language, and is not currently supposed to import whole APIs into nimrod mechanically, but rather to serve as a starting point for manual definition of interfaces to C libraries. c2nim is particularly effective in dealing with C's preprocessor macros, but is not currently capable of parsing many C header files.

Make c2nim accept more C declarations than it currently does, and produce corresponding Nimrod declarations. This can be done either by directly filling-in the missing capabilities, or by interfacing it with a mature tool for parsing C code, such as LLVM's CLang or the GCC-XML tool. If one of these tools is used, then it is expected that it would not suffice by itself, but rather augment the current c2nim parser, since these tools have their own limitations. A possible implementation might

@micklat
micklat / gist:8906673
Created February 9, 2014 22:03
mostly-isolated issue 888
import python except expr
type
# A non-borrowed (counted) reference. Avoid copying these around! Nimrod doesn't have
# the equivalent of an assignment constructor (yet?), so any copy of PyRef must be counted (use dup for that).
PyRef = object {.inheritable, byref.}
p: PPyObject
PPyRef* = ref PyRef
EPyException = object of E_Base
@micklat
micklat / py2.nim
Created February 9, 2014 18:57
a version of py2.nim that triggers a compiler error: py2.nim(97, 9) Error: identifier expected, but found '`()`*'
# A high-level wrapper for python 2.x (thus the name "py2.nim" rather than "py.nim")
# short-term TODO:
#
# * check whether the destructor gets called at all
# * support more of the API
#
# mid-range TODO:
#
# * don't print exceptions, retrieve the exception information into nimrod