Skip to content

Instantly share code, notes, and snippets.

View cgay's full-sized avatar
👖
Pants

Carl Gay cgay

👖
Pants
View GitHub Profile
@cgay
cgay / gist:577d57b9928a16b7cbc78228730a9455
Created November 22, 2023 07:22
Quicksort in Common Lisp
(defun qso (l)
(when l
(append
(qso (remove-if (lambda (a)
(> a (first l)))
(rest l)))
(cons (first l)
(qso (remove-if (lambda (a)
(<= a (first l)))
(rest l)))))))
@cgay
cgay / lexer.dylan
Created October 1, 2023 20:07
trim-multi-line-prefix
// Not debugged version that I replaced with a split/join version.
// https://opendylan.org/proposals/dep-0012-string-literals.html#the-rectangle-rule
// When this is called `string` is known to contain at least one literal
// newline character and the EOL sequence has already been canonicalized to
// just '\n'.
define function trim-multi-line-prefix
(string :: <string>) => (maybe-trimmed :: <string>)
let len :: <integer> = string.size;
// Whitespace following """ is ignored until '\n'.
@cgay
cgay / gist:30c70cec80cc243f65e0d9ac3bf85fe0
Created February 6, 2021 20:45
Unusual compiler output
-*- mode: compilation; default-directory: "~/dylan/workspaces/dt/" -*-
Compilation started at Sat Feb 6 20:33:54
cd $DT && dylan-compiler -build dylan-tool
Open Dylan 2021.1pre
Opened project dylan-tool (/home/cgay/dylan/workspaces/dt/dylan-tool/dylan-tool.lid)
Warning - Definition of {<c-statically-typed-function-pointer> in dylan-c-ffi-hygiene-glitches} is declared open, but it is not exported from this library
(This warning can be avoided by declaring the definition "dynamic" instead of "open")
@cgay
cgay / gist:316294c4ce8f970812abbebb08bcabdd
Created January 18, 2021 18:35
Link failure with different compiler
...
Build of 'dylan-playground' completed
Internal error: Link failed: Link failed: /usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_ULx86_64_init_local'
/usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_ULx86_64_get_proc_name'
/usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_ULx86_64_set_reg'
/usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_Ux86_64_getcontext'
/usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_ULx86_64_get_reg'
/usr/bin/ld: /home/cgay/dylan/workspaces/playground/_build/lib/libdylan.so: undefined reference to `_ULx86_64_step'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@cgay
cgay / dylan-compiler-crash
Created October 17, 2020 23:10
Crash while compiling playground with 2020.1 after adding regular-expressions to playground module.
Processing library play-3a7bd1e93794
65535 is not of type {<limited-integer>}
Backtrace:
invoke-debugger:internal:dylan##1 + 0x29
default-handler:dylan:dylan##1 + 0x12
default-last-handler:common-dylan-internals:common-dylan##0 + 0x2f6
error:dylan:dylan##0 + 0x23
0x7f22007f5ced
0x7f21ff7d0dfa
coerce-from-element:streams-internals:io##1 + 0x1c
@cgay
cgay / dylan-bt-error.txt
Created October 5, 2020 00:40
weird error from dylan-bt
...chop...
2020-10-05T00:24:15.000+0000 info [request worker 2] 127.0.0.1 - - [05/Oct/2020:00:24:15 +0000] "GET /x?n=0 HTTP/1.1" 599 49 "-" "-"
2020-10-05T00:24:15.000+0000 debug [request worker 2] Error handling request: End of stream {<byte-char-tcp-socket>}
C-c C-cProcess 20866 stopped
* thread #1, name = 'Main thread', stop reason = signal SIGSTOP
frame #0: 0x00007ffff78da00c libpthread.so.0`__pthread_cond_wait at futex-internal.h:88:13
(lldb) dylan-bt
error: libdl.so.2 0x7fffffff000140be: adding range [0x1550-0x155a) which has a base that is less than the function's low PC 0x1910. Please file a bug and attach the file at the start \
of this error message
error: libdl.so.2 0x7fffffff000140be: adding range [0x155e-0x1571) which has a base that is less than the function's low PC 0x1910. Please file a bug and attach the file at the start \
cd $OD/sources && dylan-compiler -build system-test-suite-app
Opened project system-test-suite-app (/home/cgay/dylan/workspaces/od/opendylan/sources/system/tests/system-test-suite-app.lid)
[============ ] Generating code for library systemcomputation {{ resolved }} := [PRIMOP raw-as-string(t26)]: Error:
Type {<llvm-integer-type> #x000000000263DF80 i64} does not match
{<llvm-pointer-type> #x0000000000F811A0 i8*}
computation if (t25) ... else ... end: Error:
Type {<llvm-integer-type> #x000000000263DF80 i64} does not match
{<llvm-pointer-type> #x0000000000F811A0 i8*}
@cgay
cgay / compile-dylan-environment.txt
Created May 23, 2020 18:50
build with package round 2
LinkDLL /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/lib/libremote-nub-skeletons.so : /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/build/dylan-environment/../remote-access-path/../remote-nub-client/../remote-nub-skeletons/remote-nub-skeletons.o /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/build/dylan-environment/../remote-access-path/../remote-nub-client/../remote-nub-skeletons/_glue.o /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/build/dylan-environment/../remote-access-path/../remote-nub-client/../remote-nub-skeletons/remote-nub-skeletons-library.o /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/build/dylan-environment/../remote-access-path/../remote-nub-client/../remote-nub-skeletons/remote-nub-skeletons-module.o
LinkDLL /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/lib/libremote-nub-client.so : /home/cgay/dylan/workspaces/od/opendylan/Bootstrap.3/build/dylan-environment/../remote-access-path/../remote-nub-client/module.o /home/cgay/dylan/workspaces/od/opendylan/B
2169 git co master
2170 choose-dylan 2019.1
2171 make distclean
2172 ./autogen.sh
2173 ./configure --prefix=${DYLAN}/opendylan-master
2174 time make
real 21m20.151s
user 27m9.866s
sys 1m11.744s
@cgay
cgay / show-class-hierarchy.dylan
Created January 14, 2020 03:49
web playground example
// Edit this code, then hit Run!
define function show-class-hierarchy (class :: <class>)
let seen = make(<stretchy-vector>);
iterate loop (class = class, indent = "")
let seen? = member?(class, seen);
let extra = if (seen?) " // (see above)" else "" end;
format-out("%s%s%s\n", indent, class, extra);
if (~seen?)
add!(seen, class);