freenode/#lisp - IRC Chatlog
Search
18:03:27
ecraven
which part of the CLHS should I look at to understand when a redefinition of a function is allowed? (interactively via SLIME on a running image)
18:04:45
anamorphic
genhash and annoyingly register-test-designator throws an error if a designator is already registered. Is there any reason why it couldn't provide a restart? I know it's a CDR2 an all, so had wondered if it's a spec thing
18:08:27
ecraven
well, can I just redefine existing any function in any package at any time, and it will work?
18:10:53
djeis[m]
On some implementations redefining functions in the CL packages triggers an error, and by the spec the consequences of those redefinitions are undefined. Otherwise, technically, yes.
18:11:25
ecraven
so if an implementation inlines some functions, it has to take care to recompile everything depending on a function if it is redefined?
18:12:36
djeis[m]
And those functions still can be redefined, you just have to recompile everything which uses those functions for the update to propogate.
18:13:34
djeis[m]
It's a bit of a pedantic distinction, but I'd say an important one- redefinition means something very specific in the case of functions, and it doesn't include things like inlined functions.
18:14:38
djeis[m]
The same thing is true of macros, really- if you redefine a macro you still have to recompile everything which uses the macro.
18:16:40
djeis[m]
Another place where that shows up is when you use 'func vs #'func. Redefinition updates the symbol, so if you call 'func it'll get updated. #'func, on the other hand, captures the actual function object and that does not get modified in-place.
18:28:14
p_l
Automatic recompile of inlining functions requires a who-calls database and most implementations don't provide one
19:19:52
stylewarning
I would be fearful of re-compiling functions I didn’t explicitly ask for, esp. if I’m developing them.
19:20:54
specbot
Constraints on the COMMON-LISP Package for Conforming Programs: http://www.lispworks.com/reference/HyperSpec/Body/11_abab.htm
19:24:43
|3b|
and redefining a function generally won't affect any running instances of that function (including those waiting on a call to some other function)
19:27:19
|3b|
also unspecified when standard functions look up function bindings from symbols, so a running (mapcar 'foo ...) might see a redefined FOO on next iteration, or not at all. next call to (mapcar 'foo ...) would see new definition though
19:28:32
|3b|
(and i doubt most user functions specify that either, but probably tend to do the lazy thing and let funcall resolve it so would see redefinitions)
19:32:31
on_ion
stylewarning: i may have been thinking of JIT in general; ie. in julia if you call a function for specialized types that has not been yet required/compiled, it will do so
19:39:34
jcowan
The question is, are running functions decompiled when they are changed out from under you?
19:54:23
on_ion
ah. julia keeps around generic versions and type-dispatched versions and etc., likely it would have the least-optimized version as the most generic
19:58:53
jcowan
explains how the Graal compiler (the latest JIT engine in Oracle JVM) dynamically deoptimizes code when its assumptions are violated.
20:00:12
jcowan
The primordial JIT (HP APL, 1977) already did this, first assuming that the rank and shape of all variables was fixed, and checking this at the beginning of a line of APL. If the assumptions were false, it deoptimized the code to assume only rank constancy, and then recompiled only if a variable changed rank (which hardly ever happens)
0:42:26
fiddlerwoaroof
I've done a bit of Haskell and work with people who write production Haskell apps
0:42:46
stylewarning
I ask because I'm wondering what folks would find convenient as an interoperable representation in Lisp.
0:43:45
stylewarning
in the sense that if you were to define an ADT in, say, Haskell, and you wanted to work with a representation of that in Lisp
0:45:28
fiddlerwoaroof
I personally prefer subclassing to model the things that Haskell/etc. uses ADTs for
0:46:13
fiddlerwoaroof
Because Haskell is built around a "closed world" assumption: its type system assumes that all the relevant types are known at compile-time
0:47:52
stylewarning
Bike: that's what I do in CL-ADT, but it has been inconvenient for re-definition, and inconvenient for creating constants
0:48:17
White_Flame
instead of symbols and simple-vectors, if you used symbol and cons type specifiers, along with OR or MEMBER types, wouldn't that cover most the bases?
0:49:04
stylewarning
Bike: Well it's not so bad, but I haven't been able to guarantee EQ-constness with structs
0:49:25
White_Flame
the most glaring (and recurring) problem with simple-vectors is that their element type is locked to T
0:50:17
fiddlerwoaroof
e.g. make None a singleton and return the single value whenever a None is constructed?
0:50:36
stylewarning
anyway the reason I ask is because i finally decided to cut all the nonsense out and take the plunge of implementing a strictly typed DSL in lisp with a focus on interoperability/incremental development
0:51:03
stylewarning
but I guess I don't know well enough all the nuance about compile-time load-time etc etc
0:53:16
stylewarning
fiddlerwoaroof: my motivation isn't really to implement a whole new language; it's more to allow one to write statically typed and statically inferred pieces of Lisp code, in a way that isn't completely hermetically sealed off from the rest of your lisp program
0:53:37
stylewarning
(e.g., to allow one to write safety-critical portions of their lisp programs in this DSL)
0:54:05
fiddlerwoaroof
Yeah, I've been wanting that too. But the main benefit of types, for me at least, is _not_ the correctness guarantees
0:54:46
fiddlerwoaroof
It's that, in a language with bidirectional type inference, you can use the types as a way to do some kinds of metaprogramming that is impossible with macros
0:55:38
stylewarning
for me, where a lot of my job is writing compilers, the safety is what i care about a lot, because compilers are big and complicated and bugs are hard to find
0:56:49
stylewarning
anyway, I have code here. It's not really functional. Maybe another weekend or two it will be a good enough MVP. Type inference works, type definitions almost work, compilation almost works, etc. https://github.com/tarballs-are-good/coalton
0:58:20
stylewarning
you can see some pedestrian examples of what does work now here: https://www.irccloud.com/pastebin/2CzwH3Iw/
1:01:56
fiddlerwoaroof
The Type Systems as Macros paper that hackett is based on is the most interesting one to me because it seems to lead to an interesting part of the design space
1:02:29
LdBeth
fiddlerwoaroof (IRC): Then the book Partial Evaluation and Automatic Program Generation is a good start
1:02:33
fiddlerwoaroof
Where, since macroexpansion and type checking are interleaved, you can do interesting code-generation things
1:03:07
stylewarning
idk, maybe. I think there's a lot of pay dirt in thinking about things with a very Common Lispy philosophy of building something useful and practical even if a bit muddy, instead of some new-fangled philosophy of program construction.
1:04:50
fiddlerwoaroof
But, if you think of a typechecker as a program that reads your code and transforms it (at least by erasing your types), it makes sense to implement it as part of the macroexpansion phase of your program
1:09:26
fiddlerwoaroof
Yeah, the relevant thing there is that it's all about proving that certain rewrites of a program don't change the semantics
1:15:42
fiddlerwoaroof
Anyways, there's way to many interesting things in Computer Science for the amount of free time I have
1:43:22
asarch
What's wrong with this compilation of SBCL in OpenBSD 6.4 for AMD64 (you have to enable the 'thread' flag in order to use McCLIM):
1:54:43
fiddlerwoaroof
One strategy that might work is download a binary of sbcl from http://www.sbcl.org/platform-table.html and then use that to build the version you want
1:56:51
fiddlerwoaroof
I clone the git repo, checkout the tag for the release I want and then do ./make.sh --fancy --prefix=$HOME/sbcl
1:57:54
fiddlerwoaroof
If you're using the binary distro, I think you need to also specify the --xc-host option, so that would look something like ./make.sh --fancy --prefix=$HOME/sbcl --xc-host=/path/to/binary/edition/run-sbcl.sh
1:58:54
fiddlerwoaroof
But, also, OpenBSD is probably a less-used platform so you're likely to find bugs
2:02:27
asarch
I'm planning to port those games from the YouTube video to Common Lisp using McCLIM (I hope at least I could one of them)
2:30:38
stylewarning
stuff that's working in Coalton https://github.com/tarballs-are-good/coalton#examples
2:49:26
adlai
dorketch: even in #clnoobs they're not gonna take kindly to multiline pastes of not understanding how the reader works.
3:05:37
pillton
stylewarning: I thought he wrote a CL in CL which was type safe. I remember something about a type safe Tcl/Tk binding.
3:14:55
pillton
stylewarning: Well, I have exceeded my time to try and find out. My memory might be failing.
3:37:59
fiddlerwoaroof
Yeah, I think there's this cultural thing that makes it so that most people are uninterested in static/dynamic interop
3:38:30
stylewarning
fiddlerwoaroof: I don't think that's true. The thing with Shen/Qi is that they're presented as a "all or nothing" solutions.
3:39:55
fiddlerwoaroof
Anyways, I've heard that Shen has pretty good interop with its host implementation
3:40:46
stylewarning
fiddlerwoaroof: Shen compiles to Lisp (or whatever host), but it doesn't appear to be *designed* to interoperate.
3:41:04
stylewarning
In the sense that the expectation is that you use Shen and the host in a mixed fashion. But I might be wrong.
4:23:06
beach
Maybe here is the answer: http://www.chiark.greenend.org.uk/doc/sbcl-doc/html/sbcl-internals/Type-tags.html
4:26:24
beach
Unless you are working on SBCL internals, you should not have to think about tags at all.
4:27:37
anniepoo
I'm writing (cleaning up) a tool to strip out a bunch of info after compilation, to deliver a minimal size runtime object file
4:30:00
beach
A great opportunity to get back into the game. Things have changed a lot since then. Not the language, but things around it.
4:30:25
beach
Even the programming style conventions change slowly over time, just like natural languages do.
4:32:15
beach
And we have (somewhat) better tools for free implementations. Genera, of course, was a lot better than what we have now.
4:32:47
aeth
stylewarning, fiddlerwoaroof: Personally, I would just use type declarations (and related type things) to mix "static" with CL. It works very well with SBCL (with safety above 0) except for :type in slots in defclass, which are only checked with (debug 2) (I think it's when the defclass is *defined* within a (debug 2)). There are some issues here or there with other implementations, but I will document them some day and hopefully those can
4:33:09
loke`
beach: I think it's more precise to say that is was better in some respects. Not everything has gone backwards :-)
4:33:31
stylewarning
aeth: I highly disagree. That requires monomorphising all data structures, and even Common Lisp is happy to have polymorphism everywhere.
4:34:36
stylewarning
aeth: But even so, ignoring that (major) aspect, it also requires heavy declare/check-type discipline, which is fine, but it gets difficult to precisely express the types you want to express without descending into a bunch of SATISFIES types. How do you express a list of symbols, in Lisp?
4:34:44
anniepoo
I know most of the fp basics- I wrote Lisp for Apple years ago. I know clojure and I'm a Prolog maven. But yeah, everything seems to have changed.
4:35:23
aeth
stylewarning: You can use https://github.com/Bike/introspect-environment directly or use something that uses introspect-environment, but unfortunately those only have access to *declarations* and not what the implementation's type inference system infers.
4:35:36
beach
anniepoo: So one thing that has changed is that more Common Lisp programs are object-oriented these days. Using CLOS, of course.
4:35:48
stylewarning
aeth: How do you express that a variable should be bound to a value which is a list of symbols?
4:36:45
beach
stylewarning: You can use regular type expressions developed by Jim Newton and Didier Verna.
4:37:17
aeth
stylewarning: The weakness is data structures, but there are ways around it. There actually is a type syntax for cons cells, but afaik it probably is O(n). What I did was define a struct that has foo as a foo-car and itself or nil as the foo-cdr (an alternative could permit trees at the cost of not being able to O(1) check that it's a proper list)
4:38:33
stylewarning
Lisp can express a huge variety of data structures, like lists of symbols, for example.
4:38:40
anniepoo
IIRC the first time I ran into keywords :foo was when I started clojure. I don't remember them from whatever ancient version of lisp I was using at apple
4:39:41
aeth
stylewarning: :type in struct slots tends to be respected, and works very well in SBCL. But now you're mostly stuck with structs and functions/lambdas/lets. And you don't really have a good way to deal with ftypes, even in SBCL.
4:41:52
stylewarning
aeth: I think you're still overestimating the compile-time safety afforded by type annotations with SBCL for a project like building a compiler. :)
4:42:15
anniepoo
it was an internal tool for Apple - maintaining fonts was painful, I wrote a font compiler-decompiler that turned them back and forth into s-expressions
4:43:26
aeth
stylewarning: SBCL will statically type check within a compilation unit or file, and if you turn on sb-ext:*derive-function-types* (off by default because it violates the standard) it will assume that ftypes will not change even if the function is redefined and will do even more static type checking. You might have seen the former before if you redefine a function with C-c C-c and SBCL gives a type error.
4:44:00
fiddlerwoaroof
anniepoo: (don't answer if you don't want to connect identities) but, were you the run offering the prolog course on twitter?
4:46:02
anniepoo
https://cutebouncingbunnies.wordpress.com/2017/04/25/the-standard-sequence-for-prolog/
4:46:08
fiddlerwoaroof
cool, I wanted to participate, but I was too busy moving/etc. to actually do anything
4:46:31
anniepoo
send an email to anne@swi-prolog.org saying you want to be informed next time it's offered
4:46:59
aeth
stylewarning: Anyway, I don't think what's there for types is satisfactory, but it's something that hopefully will be extended in the future, particularly with non-T data structures (when I write in this style I'm basically stuck with structs and my custom metaclass), generics, and ftypes.
4:47:25
loke`
LdBeth: I downloaded Pharo and then found soem online tutorials. That's how I started looking at ST
4:49:34
fiddlerwoaroof
aeth: that's good for performance critical code but it's effectively turning Common Lisp into Pascal or Java 1.1
4:50:36
fiddlerwoaroof
The things that make Common Lisp pleasant are things like generic functions, clos and various other higher-order techniques
4:51:57
fiddlerwoaroof
(at least, CLOS and generic functions and the condition/restart system are the main reasons why it's my favorite language)
4:53:58
stylewarning
If the claim is that adding strong type decls turns parts of your program into Pascal-y code, then I agree.