Skip to content

Instantly share code, notes, and snippets.

View nyuichi's full-sized avatar

Yuichi Nishiwaki nyuichi

View GitHub Profile
; 用語
; - variable: identifierとsymbolの総称
; すべての基本:識別子オブジェクト
; R4RSの言葉でいうと、eq?な識別子オブジェクトがbound-identifier=?、equal?な識別子オブジェクトがfree-identifier=?になる。
; identifier=?な識別子オブジェクトはコンパイル後には同じ変数を指すことになる。
; equal?は識別子どうしを比較するときはidentifier=?を呼ぶ。
(identifier? obj)
; すべての基本:識別子オブジェクト
; R4RSの言葉でいうと、eq?な識別子オブジェクトがbound-identifier=?、equal?な識別子オブジェクトがfree-identifier=?になる。
; equal?は識別子どうしを比較するときはidentifier=?を呼ぶ。
(identifier? obj)
(identifier=? id ...)
(make-identifier id env)
(symbol->identifier sym [env])
(identifier->symbol id)
(define (p obj)
(write obj)
(newline)
(flush-output-port)
obj)
; expecting:
;
; (let-in-order ((x 1)
; (y 2))
; tmpをrenameで作るのは間違ってる(というのがここでの主張)
; 単純なsymbol-to-symbolのα変換(capture-avoiding substitution)のうえに
; erを作っているとsrfi-72のlet-in-orderのような場合にバグる。
; picrinでいうと、このissue -> https://github.com/picrin-scheme/picrin/issues/36
(define-syntax swap!
(er-macro-transformer
(lambda (e r c)
(let ((a (car (cdr e)))
(define-library (foo bar)
(import (picrin base))
(begin
(define (foo)
(display "foo"))
(define-syntax macro1
; ここではfooは見えない
...))
(import (rename (picrin base) (define real-define)))
(define-syntax my-lambda
; support docstrings
...)
(define-syntax my-define
(syntax-rules ()
((_ var val)
(real-define var val))
(*
OCaml translation of the ideas explained in http://fumieval.hatenablog.com/entry/2014/09/22/144401
To emulate the higher kinded polymorphism, the technique used explained in https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf
*)
module StateMonad = struct
type ('s, 'a) m = 's -> 's * 'a
(define-nitro r7rs
(require callcc mutable-string))
@nyuichi
nyuichi / boot.c
Last active August 29, 2015 14:06
#if 0
use strict;
open IN, "./boot.c";
my @data = <IN>;
close IN;
open STDOUT, ">", "./boot.c";
#if 0
# ここはperlスクリプト(quine)
compile_and_save <<EOL
; ココはschemeスクリプト
(define (my-standard-function ...)
...)