freenode/#lisp - IRC Chatlog
Search
4:23:10
didi
Sooo. I want to use `assert' within `defsetf'. The problem is, the place I use inside `assert' turns into an `undefined variable'. I can do it, if instead of `defsetf', I use `defun (setf ...) ...'. Is there a way to use `assert' within `defsetf'?
4:23:10
minion
didi, memo from pjb: there are downsides in using :type : then you won't be creating a new type, so it'll be harder to distinguish those structure instances from lists (or vectors). So you would do that, only when this would be the point.
4:31:41
Bike
in the expansion function, ONLY-NUMBER will be bound to a symbol. the expansion of setf will bind that symbol to whatever. so it names a place.
4:34:14
didi
Oh well. I should have actually tried, instead of reading the macro expansion. Sorry for the noise.
4:41:05
didi
Ah, right. The trouble program is https://paste.debian.net/hidden/cf0b6b87 . The issue is with the function parameter, not with the new value.
4:42:08
didi
Now SBCL complains. If I try (setf (my-place 0 (list 1 2 3)) 42), "Variable name is not a symbol: 0."
4:44:14
didi
I guess if I want to use `assert', I will have to live with the #'(setf ...) function call.
4:49:51
didi
OK, `(let* ((n ,n)) (assert (numberp n) (n)) (setf (nth n ,list) ,value)) works, but at what cost? Maybe it's better to use (setf my-place) after all.
4:50:46
pjb
didi: I think that the point is that when you use defsetf it doesn't create a (setf foo) function, but setf expands the expression inline.
4:53:18
didi
I also noted that (nth 42 '()) evals to NIL but (elt '() 42) signals a condition. Weird.
4:58:06
aeth
Well I expect the main difference to be that NTH will have an error if not given a list and ELT will work fine if given certain non-lists
5:02:58
pjb
Well, one could expect that elt would still avoid calling length on lists. So it could return nil or signal an error at the same cost.
5:03:18
pjb
But since nth already returned nil, it was more interesting to return an error, just like in the case for vectors.
5:51:00
beach
Yes, but I don't understand your first question. Mainly because I don't understand the grammar of the sentence.
5:51:59
sthalik
beach, there was this basic idea that the standard's immaculate, and it doesn't need anything new ever, at all
5:54:07
beach
sthalik: Also, fast portable sequence functions: http://metamodular.com/sequence-functions.pdf
6:19:20
sthalik
beach, having passed some datum to the pattern-matching macro, have the compiler guarantee that all cases are taken care of
6:26:46
aeth
You can define a member type with a custom macro that also defines a custom ecase. The custom ecase can verify that every member in the member type foo is a clause in the foo-ecase macro and only members of that member type foo. At compile time. Afaik. It doesn't sound particularly hard, either.
6:27:13
aeth
Now, that's just a tiny part of the problem, but I think the basic solution form would hold. Generate a function and a macro in a macro, and call that function in the macro to verify that the macro is valid
6:28:02
sthalik
aeth, compilers like SBCL have inference done on the matched datum. can you access that?
6:28:54
aeth
I don't think you can access SBCL's type inference. At least, I haven't seen a library do that. You'd have to use type declarations if you can't.
6:29:24
sthalik
aeth, can a pattern-matching library like that access, say, CHECK-TYPE or DECLARE TYPE?
6:30:06
aeth
specialization-store, an otherwise wonderful library for type-based generic functions, cannot access anything other than type declarations from DECLARE as well as FTYPE declarations afaik.
6:30:22
aeth
If you haven't seen it, this is the library. https://github.com/markcox80/specialization-store/
6:31:03
sthalik
aeth, but a pattern-matching library won't infer (or access the info from the compiler) whether the pattern is exhaustible, will it?
6:32:32
aeth
I don't think there's any more information available at compile time than the information that's in introspect-environment, but I could be wrong. If there is, it would be incredibly non-portable.
6:33:14
aeth
I'm guessing there isn't more because there are libraries that could benefit from more.
6:36:25
aeth
If someone could port some of SBCL's behavior to CCL, it would no longer become implementation specific!
6:41:07
aeth
sthalik: What do you have in mind? Can you put some invalid code in a pastebin that you wish would work?
6:44:59
sthalik
aeth, rather, what's potentially recognized as valid that ought be guaranteed recognized as invalid
7:00:44
lieven
ACTION must have missed the many times Harrop was right. The arrogant part is spot on.
7:03:04
sthalik
lieven, people engaging in the arguments on Lisp's side made a straw man out of type systems so Harrop had an easy time
7:05:06
sthalik
aeth, Lisp side: type systems peak at C89. pattern matching doesn't improve program flow
7:07:50
jackdaniel
sthalik: unless it is a type based on `satisfies', then function associated with it may compare object with anything
7:08:30
aeth
sthalik: The built in typed conses are... lacking in many ways. However, most implementations now (or hopefully soon) enforce :type in slots on structs, so you can create your own typed cons.
7:09:43
lieven
the lisp side argument was mostly that lisp is a dynamic language and that so far attempts to mesh a static type system with it are clumsy.
7:10:10
aeth
sthalik: https://gitlab.com/zombie-raptor/zombie-raptor/blob/93ddd7250aba57a22817defadf6cc45176109926/util/util.lisp#L402-463
7:10:32
aeth
It's getting increasingly messy, though, so I might use inline specialization-store specializations instead of prefixes.
7:11:17
aeth
The core of it is just a three line defstruct to have a car of type and a cdr of (or null type-cons)
7:11:37
aeth
Yes, it's not as powerful as a Lisp cons and is only for lists. A separate kind of cons could be created for trees that has less guarantees.
7:13:35
aeth
Now, there's lots of things about type systems that are lacking in CL, but typed conses via structs seem to be doable. Probably even immutable ones with :read-only, although probably not useful without the language itself optimizing them
7:14:35
sthalik
technically one can "freeze" a definition but then it's the "sufficiently smart compiler" fallacy
7:17:27
aeth
I do think that if CL has a weakness it's in its limited set of collections available, especially lacking in immutability and non-generic versions (except for specialized arrays).
7:18:26
aeth
e.g. If CL had built-in hash tables that could only hold type foo, then the compiler would know on the GETHASH what the type is (if it knew the type of the hash table), which would remove a lot of declare/the/check-type/etc.
7:21:21
aeth
One problem with :element-type is that you can't e.g. store (integer 0 10), it'll round it to probably (integer 0 15) or something.
7:21:50
aeth
Sure, internally, it should round it, but it would be nice if it actually remembered you wanted to store (integer 0 10) so the type information isn't lost across the function boundary.
7:23:29
aeth
SBCL has sb-ext:*derive-function-types* which when enabled allows the non-standard behavior of assuming that the ftype of a function will never change.
7:24:44
aeth
It's good to have that option, but you still lose information in data structures like hash-tables and lists
7:24:48
sthalik
what's the purpose of statically-knowing the element type being fixnum between 0 and 10?
7:25:42
aeth
If for some reason you add (- most-positive-fixnum 20) or something, it knows it stays as a fixnum and so uses much faster arithmetic
7:28:51
aeth
I personally have a define-function macro, so in my game engine I would write it as (define-function foo ((x (integer 0 10))) (+ (- most-positive-fixnum 10) x))
7:29:45
aeth
Usually SBCL does a good job at deriving the return type and I don't think the other implementations have an ftype so I don't care about supporting return types. At some point I'd support it as an option
7:30:36
aeth
But I think that would require a third generated defun so I have been procrastinating that
7:35:24
sthalik
now that I think of, the argument-environment bits for a walker aren't even necessary
7:37:17
aeth
sthalik: Personally, I preallocate everything that I can and use dynamic-extent on the rest. This is a bit... eccentric and no one else in #lispgames has a game loop style remotely as restrictive as this.
7:38:20
aeth
This is for the engine's game loop only, though. I don't think I'd ever finish anything if I tried to use this style for the whole program.
7:40:32
aeth
Everything called from zombie-raptor/core/window::game-loop doesn't cons in SBCL. It's too hard to profile other implementations for this, and possibly impossible even if I could profile them.
7:41:14
aeth
(Obviously if I loaded assets while the game loop was running I wouldn't be able to keep this restriction to this extreme anymore.)
7:44:07
aeth
The way my engine is structured, it doesn't even load images! I have loaded images before in some of my unpublished tests, but I feed in the texture assets to the make-window function.
7:48:04
sthalik
in multiple C++ projects I've hit a roadblock where there's a decent amount of top-down design that can't go away
7:53:20
sthalik
even at this point there's no remote equivalent of lexical non-local return in fancy static languages
7:54:16
sthalik
aeth, what good are games if they're just iterative improvements? if it's ever done, it must transgress boundaries and do what was thought to be not feasible
7:55:06
sthalik
aeth, Falcon 4.0 included a persistent ground/air war simulation. post-mortem interviews explained "we didn't know any better"
7:57:24
aeth
I think the limiting factor is normally art. When the game devs don't care about art (e.g. Dwarf Fortress) they can do ridiculous things
7:58:03
aeth
On the other hand, when something's AAA photorealistic, everything is so expensive to make *and* you don't want to increase the risk by venturing too far from the formula
8:00:32
aeth
I plan on doing space games, at least for now. Space is mostly empty. No, even more empty than that.
8:01:50
sthalik
there's a modern maintained F4 derivative based on stolen code. current copyright holders allow it as a gentleman's agreement.
9:49:07
aeth
p_l: Well, #lispcafe does a very bad job at enforcing off-topicness and is often about Lisp.
10:46:46
thekolb
Xach: I have this weird situation where a dependency wants asdf3 but my quicklisp has asdf2? I did update-client but that didn’t upgrade asdf?
10:47:20
thekolb
(don’t ask me how I ended up with a dependency that wants asdf3 in the first place, good question though)
10:52:22
Shinmera
Also lots of dependencies require ASDF3 nowadays (for instance: all of my libraries)
11:00:42
jackdaniel
thekolb: asdf is not part of the standard (given how it constantly changes that would mean that our standard is progressing!). You may download lastest asdf relase, compile it and put (load …) in your .cclrc before loading quicklisp
11:19:36
thekolb
MichaelRaskin: the ccl package on NixOS is broken (doesn’t set CCL_DEFAULT_DIRECTORY)
11:22:20
thekolb
MichaelRaskin: CCL_RUNTIME has no effect on ccl whatsoever and seems to be a variable introduced by the Nix expression for referencing the kernel
11:23:00
thekolb
MichaelRaskin: CCL_DEFAULT_DIRECTORY is a variable used by ccl to refer t its installation destination
11:24:55
thekolb
MichaelRaskin: Not really, you should make sure that $(which ccl) sets CCL_DEFAULT_DIRECTORY appropriately and execs the kernel
11:25:57
thekolb
I.e., set CCL_DEFAULT_DIRECTORY in https://github.com/NixOS/nixpkgs/blob/release-18.03/pkgs/development/compilers/ccl/default.nix#L79
11:31:50
MichaelRaskin
env -i $(test-build -test ccl)/bin/ccl -e "(require :asdf)" -e "(print (find :asdf3 *features*))" -e "(quit)"
11:33:15
MichaelRaskin
If I don't pre-require :asdf, it is not found — again, with or without CCL_DEFAULT_DIRECTORY
11:35:52
MichaelRaskin
CCL 1.11.5 in master includes ASDF3 (even without CCL_DEFAULT_DIRECTORY variable set), maybe stable has an older one?
11:39:19
MichaelRaskin
Yes, and I have the change and I want to test one of these things before pushing to master
11:49:02
unanimousarc
Hello, new person here, if I invoke (ql:quickload x) will that package remain installed for future sessions?
11:49:11
thekolb
MichaelRaskin: I did nix-env -f https://github.com/NixOS/nixpkgs/archive/master.tar.gz -i ccl and ccl -n -e "(ignore-errors (require 'asdf))" -e "(quit (or (find :asdf3 *features*) 1))"; echo $?
11:49:50
MichaelRaskin
thekolb: I think CCL defaults to the image location if CCL_DEFAULT_DIRECTORY is unset; given the details of the Nix package that seems to mean the variable is irrelevant
11:49:55
phoe
unanimousarc: quicklisp fetches the dependencies from the network and then invokes ASDF to load the system into memory.
11:50:10
phoe
the former is persistent, the latter needs to be done after each reload of the Lisp image.
11:50:36
phoe
you can theoretically save the resulting Lisp image and then reload that one, but it's not commonly done during development - better to just #'ql:quickload things again.
11:57:06
MichaelRaskin
If you run «which ccl», do you actually get the version in the profile? If you just run CCL, what version is reported?
12:06:06
MichaelRaskin
Well, in a fresh test account I use your installation command (well, with -p, I have a complicated non-default setup) — it gives CCL which loads ASDF3
12:10:13
MichaelRaskin
Well, I could try to pastebin a nix-expression that imports from a fixed revision and checks CCL in build-time — failure-or-success of Nix builds is less environment-dependent than installation
12:13:27
MichaelRaskin
Does this also error: env -i /nix/store/32xnrnrf399nxf616fxihx00qi6xb4mv-ccl-1.11.5/bin/ccl -n -e '(require :asdf)'
13:12:56
AeroNotix
What's the cheapest / easiest way to represent infinity that allows me to compare it with numbers.
13:13:20
AeroNotix
I.e. I want to have a representation of infinite that I can do things like (< 123 +infinity+)
13:16:11
Shinmera
In Trial I've been doing https://github.com/Shirakumo/trial/blob/master/toolkit.lisp#L32-L38 so far
13:23:36
AeroNotix
v0|d: I used the sb-ext ones for now. I'll find something more portable later. It's only for a debugging thing right now anyway
13:54:36
Shinmera
unanimousarc: It's not a recommendation, but here's mine. http://blog.tymoon.eu/tagged/common%20lisp
14:15:26
LiamH
AeroNotix: If you don't mind loading a foreign library, GSLL has it: (< 1.0 gsl:+positive-infinity+) => T
14:44:58
Shinmera
Speaking of twitter, there were some API deprecations regarding direct messages that I haven't had time to fix in Chirp.
15:00:27
drmeister
With asdf - is there a way to get a tree of dependencies from a system? I have a groveler that I use for finding all files required by a system in the order that they need to be loaded.
15:00:44
Shinmera
Ha ha, oh boy the CCL source for infinity-p has a comment: ; not sure this is right
15:01:00
drmeister
The groveler has a function that says it returns all of the systems required by given list of systems. I think this may be what I need.
15:01:30
drmeister
I want to parallelize the building of the tree - so I need to know what it looks like first.
15:02:18
drmeister
If it's a linear sequence - well - then I need to put some work into splitting things out a bit to make it a tree.
15:02:48
drmeister
Shinmera: Thank you - I'll keep spitting out what I'm looking for - maybe someone will have some thoughts on it.
15:03:10
pjb
AeroNotix: if you want to compare with numbers, you have a big problem: numbers are not ordered!
15:03:22
drmeister
Then I'll need to time how long each system needs to build it - then I want to organize the build so that it takes as little time as possible using multiple processes.
15:03:30
pjb
AeroNotix: in lisp, numbers include complex numbers, and complex numbers are not ordered.
15:03:54
Shinmera
drmeister: https://github.com/Shirakumo/radiance/blob/22cdcde8be60f5e49e90a59f7375ceea130358c7/migrate.lisp#L131-L150
15:04:13
drmeister
Basically - I want to parallelize the building of a large collection of asdf systems so they build as quickly as possible. Given that POIU is MIA for current versions of ASDF.
15:04:30
pjb
AeroNotix: then if you want to restrict yourself to real, then in lisp we have most-positive-long-float that is bigger than all floats, but not to all integers.
15:07:01
pjb
AeroNotix: at a given time, there's a maximum representable integer, but since it may depend on the available memory, it may grow later.
15:12:08
pjb
AeroNotix: you may also shadow < <= etc. calling cl:< cl:<= etc when you only have numbers.
15:13:02
pjb
See for example: https://github.com/informatimago/lisp/blob/master/common-lisp/invoice/invoice.lisp#L366
15:24:09
drmeister
Shinmera: Is the information about system dependencies available after I load-asd - or do I need to load-system everything?
15:25:30
jackdaniel
drmeister: you need to load all asd file (i.e by find-system), but there is no need to load systems into the image
15:26:13
jackdaniel
it is quite problematic as it is anyway, because asd files are programs, but not as bad as being forced to load all libraries to learn their dependencies
15:26:44
Shinmera
jackdaniel: Does ECL have something similar to sb-int:with-float-traps-masked that allows you to mask which floating point traps signal conditions?
15:27:41
Shinmera
drmeister: It only loads a system file if it has to due to :defsystem-depends-on or due to find-system
15:44:44
drmeister
How does one redirect the ~/.cache directory so that quicklisp/asdf drop the generated code somewhere else?
15:47:16
jackdaniel
"A specification as per RESOLVE-LOCATION of where the user keeps his FASL cache")(defvar *user-cache* nil
15:47:19
jackdaniel
"A specification as per RESOLVE-LOCATION of where the user keeps his FASL cache")