Skip to content

Instantly share code, notes, and snippets.

Avatar

Siddharth bollu

View GitHub Profile
@bollu
bollu / let-star-terrible-compiler-error.lisp
Created January 10, 2022 18:00
Why does SBCL not warn that the let* makes no SYNTACTIC sense?
View let-star-terrible-compiler-error.lisp
(defgeneric errormsg (x))
(let* (x (errormsg nil)) x)
;; [slime-compile-defun]
;; cd c:/Users/bollu/quicklisp/local-projects/hoopl/src/hoopl/
;; 1 compiler notes:
;;
;; hoopl.lisp:244:1:
;; style-warning: The variable ERRORMSG is defined but never used.
@bollu
bollu / error
Created January 8, 2022 14:35
c2mop usage does not compile correctly
View error
hoopl.lisp:175:56:
read-error:
READ error during COMPILE-FILE:
Package C2MOP does not exist.
Line: 175, Column: 56, File-Position: 5631
Stream: #<SB-INT:FORM-TRACKING-STREAM for "file c:\\Users\\bollu\\phd\\mlir-hoopl-rete\\src\\hoopl\\hoopl.lisp" {25891499}>
@bollu
bollu / common-lisp-backtrace
Created January 7, 2022 15:21
Learning how to use the SBCL+sly debugger
View common-lisp-backtrace
0: ("undefined function" #<STANDARD-CLASS COMMON-LISP-USER::INST-ADD>)
1: ((:METHOD DEEPEQ (T T)) #<INST-ADD {1001E94723}> #<INST-ADD {1001E947A3}>) [fast-method]
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEEPEQ (MK-INST-ADD :X :Y 1) (MK-INST-ADD :X :Y 1)) #<NULL-LEXENV>)
3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (ASSERT-EQUAL (DEEPEQ (MK-INST-ADD :X :Y 1) (MK-INST-ADD :X :Y 1)) T) #<NULL-LEXENV>)
4: (EVAL (ASSERT-EQUAL (DEEPEQ (MK-INST-ADD :X :Y 1) (MK-INST-ADD :X :Y 1)) T))
5: (SLYNK::EVAL-REGION ";;;; -*- Mode: Common-Lisp; Author: Siddharth Bhat -*- ..)
6: ((LAMBDA NIL :IN SLYNK:INTERACTIVE-EVAL-REGION))
7: (SLYNK::CALL-WITH-RETRY-RESTART "Retry SLY interactive evaluation request." #<FUNCTION (LAMBDA NIL :IN SLYNK:INTERACTIVE-EVAL-REGION) {10015A3F$ 8: (SLYNK::CALL-WITH-BUFFER-SYNTAX NIL NIL #<FUNCTION (LAMBDA NIL :IN SLYNK:INTERACTIVE-EVAL-REGION) {10015A3F4B}>)
9: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SLYNK:INTERACTIVE-EVAL-REGION ";;;; -*- Mode: Common-Lisp; Author: Siddharth Bhat -*- ..)
10: (EVAL (SLYNK:INTERACTIVE
View deep-equality.lisp
;; equivalent upto structure
(defgeneric deepeq (x y))
(defmethod deepeq ((x number) y)
(equal x y))
(defmethod deepeq ((x symbol) y)
(equal x y))
(defmethod deepeq (x y)
View slots-initargs.lisp
;; quoted initarg
(defclass foo ()
((foo-field :initarg foo-initarg :accessor foo-accessor)))
(defparameter *foo* (make-instance 'foo 'foo-initarg 10))
;; symbold initarg
(defclass bar ()
((bar-field :initarg :bar-initarg :accessor bar-accessor)))
(defparameter *bar* (make-instance 'bar :bar-initarg 10))
@bollu
bollu / hoopl-clos.lisp
Last active January 6, 2022 04:56
Partial hoopl implementation in common lisp, put up for critique
View hoopl-clos.lisp
;;;; -*- Mode: Common-Lisp; Author: Siddharth Bhat -*-
;;;; https://google.github.io/styleguide/lispguide.xml
;;;; https://jtra.cz/stuff/lisp/sclr/index.html
;;;; https://lispcookbook.github.io/cl-cookbook/data-structures.html
;;;; https://github.com/bollu/mlir-hoopl-rete/blob/master/reading/hoopl-proof-lerner.pdf
;;;; https://learnxinyminutes.com/docs/common-lisp/
;;;; https://lispcookbook.github.io/cl-cookbook/clos.html
;;;; https://malisper.me/debugging-lisp-part-1-recompilation/
;;; errors and restarts:
View bench-oct-15-remove-isdefault-simpcase-guard
Report for stdlib
stdlib [0] ( 2 single benchmarks)
wall-clock mean = 241.(113), deviation = 10.59262%
stdlib [1] ( 2 single benchmarks)
wall-clock mean = 211.(160), deviation = 20.19648%
Equal program blocks
stdlib [0] ⟷ stdlib [1]
wall-clock confidence = 61%, speed up = 12.42%
@bollu
bollu / issue.md
Last active October 4, 2021 15:41
PANIC at Lean.Expr.bindingDomain! Lean.Expr:618:23: binding expected
View issue.md

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

The compiler panics with the error:

View arith-with-normal-plus-times.lean
-- example on parsing arith language via macros
inductive Arith: Type :=
| Mul : Arith -> Arith -> Arith -- e :* f
| Symbol : String -> Arith -- variable
declare_syntax_cat arith
syntax term : arith -- int for Arith.Int
syntax str : arith -- strings for Arith.Symbol
syntax:70 arith "*" arith : arith -- Arith.Mul
View mutual_implemented_by.lean
nductive Foo
| mk: Int -> Foo
instance : Inhabited Foo where
default := Foo.mk 42
constant odd : Int -> Foo
constant even : Int -> Foo
-- | in reality these are partial mutually defined functions.