Skip to content

Instantly share code, notes, and snippets.

View belmarca's full-sized avatar

Marc-André Bélanger belmarca

  • Montréal
View GitHub Profile
@belmarca
belmarca / README.md
Created February 17, 2020 05:49
Gerbil library relative imports
➜  somewhere pwd
/tmp/somewhere
➜  somewhere tree
.
├── mylib
│   ├── gerbil.pkg
│   ├── module1.ss
│   ├── module2.ss
│   └── utils
@belmarca
belmarca / README.md
Created February 17, 2020 04:14
Jmabsd gerbil example

Jmabsd gerbil example

Put utils.ss in /tmp/my-gerbil/lib/example. Go to your /example dir. Do gxc -d /tmp/my-gerbil/lib utils.ss.

Get:

➜ my-gerbil pwd
@belmarca
belmarca / pyg.c
Created February 8, 2020 04:56
Naive Python<->Gambit type conversions
#define PY_SSIZE_T_CLEAN
#include <Python.h>
// Python 3.x only
___SCMOBJ SCMOBJ_to_PyObject(___SCMOBJ from, PyObject* to)
{
if (___TYP(from) == ___tSUBTYPED)
{
switch (___SUBTYPE(from))
@belmarca
belmarca / build.ss
Created February 6, 2020 19:25
Keccak in Gambit
#!/usr/bin/env gxi
(import :std/build-script
:std/make)
(defbuild-script
`((gxc: "keccak.ss"
"-ld-options" "-L/usr/lib/x86_64-linux-gnu -lcryptopp"
"-cc-options" "-I/usr/include/crypto++")))
@belmarca
belmarca / app.py
Created January 28, 2020 18:51
Example custom runtime Gambit-C Python Universal Backend
#! /usr/bin/python
# File generated by Gambit v4.9.3
# Link info: (409003 (python ()) "test_" (("rts") ("test")) (r2 r3 stack sp r0 ffi nargs wrong_nargs r1 string pollcount poll check_procedure_glo glo glo-println make_interned_symbol peps module_register null_obj modlinkinfo module_registry_init) (println print rts test ##program-descr ##apply-global-with-procedure-check-nary) (##vm-main-module-id println test# print rts# ##program-descr) (println print ##program-descr) #f)
from array import array
import ctypes
import time
import math
import sys
import weakref
@belmarca
belmarca / readme.md
Created January 28, 2020 18:11
Gambit-C Python Universal Backend

Building the runtime library

Go to your gambit directory:

cd /path/to/gambit
cd /lib
make _gambit.py
cd ..
gsc/gsc -:=. -target python -exe /path/to/script.scm
cd /path/to
@belmarca
belmarca / HEAD.ss
Created January 4, 2020 05:53
iter-opt
(import :std/iter)
(def long-string (make-string 100000))
(def (string-iter s)
(let (sl (string-length s))
(for (i (in-range sl))
(string-ref s i))))
;; (lambda (#0=#:s48)
@belmarca
belmarca / run-macro.ss
Last active November 4, 2019 21:25
example for ober
;; run-macro.ss
(import :std/actor
:std/iter
:std/srfi/13
:std/misc/process
:gerbil/gambit/threads)
(def (cmd-actor)
(let lp ()
@belmarca
belmarca / defquasiparser.md
Created October 30, 2019 18:06
defquasiparser doc

defquasiparser

(defquasiparser id rt-symbol-proc output-proc expand-time-eval) -> quasistring parser

  id               := id of the quasistring parser
  rt-symbol-proc   := unary procedure applied to symbols in run-time template variables
  output-proc      := unary procedure that the quasistring parser expands to
  expand-time-eval := boolean, allow expansion-time template variables?
@belmarca
belmarca / packages.el
Created October 29, 2019 14:56
spacemacs config
;;; packages.el --- gerbil layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: belmarca <belmarca@belmarca>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3