freenode/#lisp - IRC Chatlog
Search
12:57:25
phoe
But my question maybe can be better worded as, can I DECLAIM FTYPE of a generic function?
12:59:05
phoe
then I guess I have found a minor annoyance in SBCL, unless I am wrong somewhere again. https://plaster.tymoon.eu/view/784#784
13:00:54
loke
phoe: Aren't you supposed to put the ftype proclaimation before defining the function?
14:22:10
loke
beach: This is the current brain dump: https://drive.google.com/file/d/1aaVZmegLT42ur17j7Vbtdh7auco7pmYN/view?usp=sharing
14:22:37
loke
Here's the repository, but there isn't much in it: https://github.com/lokedhs/lisp-pref
14:25:07
phoe
loke: your work partially overlaps with my PROTEST way of declaring configuration categories and configuration options.
14:26:49
phoe
DEFINE-TYPE is not the best name because it directly clashes with CL:DEFTYPE. Maybe something more verbose like DEFINE-CONFIGURATION-TYPE?
14:27:32
phoe
:STRUCTURE :STRING is unclear to me. I don't yet get what it does, and also you missed a closing paren. (:
14:28:56
phoe
Using hash-tables is a better idea. Any list of non-null lists is a valid alist, and therefore you might avoid type confusion by using hashtables.
14:31:26
phoe
So it is obvious that you don't want just a mere tree of valid lists, and instead you want an actual map from keys to values.
15:21:38
comborico1611
Which word would you use to describe the difference between a Lisp REPL to that of all the other programming language REPLs? I was thinking "memory".
15:30:18
comborico1611
shka_: Hmm. There may be more than one difference then. I was thinking on the ability to load a function onto the REPL and then call it again.
15:40:54
phoe
comborico1611: integration of the REPL with the inspector, debugger, stepper and so on
15:41:09
phoe
nowadays it isn't about the REPL itself, it's about how it integrates with everything else
15:46:30
Beepy
shka_, it looks like Rove is still by Eitaro Fukamachi, so it will probably replace Prove at some point.
16:18:09
phoe
I've only started to rewrite my old code using my new version of PROTEST and I'm already uncovering things that I should have done better back in the day
16:18:32
phoe
such as discovering that I have duplicated DEFGENERICs and I should instead create a new mixin
16:47:42
phoe
on_ion: a mixin is a superclass that is meant to be "mixed in" with other superclasses.
17:22:50
phoe
In PROTEST, a category is not particularly interesting - the category only really exists to be a reference for the programmer, and for having a docstring.
17:22:59
loke
(besides, protest is definitely somehting I need. Potato has already changed test frameworks once)
17:23:11
phoe
And a configuration entry is essentially what you describe - a value, accessed by a list of keywords.
17:24:47
phoe
loke: PROTEST isn't an abstraction over different testing libraries. It still forces you to write tests in a given test library, but it provides mechanisms for generating test cases that are textual descriptions of tests, and therefore independent of given test implementations.
17:26:09
phoe
loke: a library abstracting over multiple different testing framework would be a testing framework itself. And we already have enough of these.
18:49:58
vtomole
Why does "(defparameter 1st '(a b c)) (nreverse 1st) (C B A) 1st " return "(A)" and not the reversed list?
19:49:40
White_Flame
comborico1611: the Lisp REPL has the full power of source code files. Many other languages don't have that ability
20:16:05
pjb
first (nreverse 1st) is not defined, because nreverse will try to mutate the literal (a b c) returned by quote.
20:16:49
pjb
then the mutation itself is not defined, so you can obtain any result for the third expression.
20:17:22
pjb
more precisely 1st will still be bound to the same cons cell, but the following cons cells (in the cdr chain), and the elements (in the cars) can be anything.
20:19:41
pjb
vtomole: the correct way to do something like that, if that's what you want to do, would be:
20:19:41
pjb
(defparameter *1st* (list 'a 'b 'c)) (setf *1st* (nreverse *1st*)) (equalp *1st* '(c b a))
20:29:08
pjb
(let ((direct (list 1 2 3))) (let ((rev (reverse direct))) (list direct rev))) #| --> ((1 2 3) (3 2 1)) |#
20:32:51
pjb
vtomole: not more efficient. If you use them when you should not, you will spend more time debugging your code than you will be able to recover ever in processing time.
20:38:00
pjb
vtomole: basically, the only safe circumstances, is when you're mutating a list that you've just constructed, so you're sure there's no other references to these cons cells. If you use it on function parameters, expect pain.
21:05:28
Kundry_Wag
Hey, this question uses Clojure but I'm posting it here since it's actually applicable to any Lisp
21:05:34
Kundry_Wag
I have a question about simulating certain aspects of a type system. There's a Clojure library called Schema that can (among other things) check the inputs of functions. For example, using Schema, one could define a Foo model - basically, a map that has some mandatory keys such as Bar and Baz. So if you define a function to have Foo as input, as in
21:05:50
Kundry_Wag
then when a-function is called, it'll check if the input matches the declared type.
21:05:51
Kundry_Wag
The thing is that if you get `obj` and, say, add other key and value to it with `assoc`, Schema won't complain, as it just checks `a-function` input:
21:05:58
Kundry_Wag
That's because Schema can't just guess that the thing we are adding a key/value must remain a Foo (if that's our goal).
21:06:00
Kundry_Wag
My question is: is that assumption true? Is technically possible to create a library that if a modified obj is always a Foo inside the function? Perhaps using some magic macrology?
21:14:26
Bike
(defn a-function [obj :- models/Foo] ...) means it takes one argument called obj, which is a Foo?
21:14:42
Bike
you'd have to do some pretty fancy stuff, yeah, to essentially use a different function also named 'assoc'
21:15:45
Bike
given that you could use a nonconstant key, something would have to be prepared to check validity at runtime.
21:17:52
Kundry_Wag
Bike: From the Clojure docs: `When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s).`. So if a-map is {:key1 :value1}, then (assoc a-map :other-key :other-value) would result in {:key1 :value1 :other-key :other-value}
21:20:24
Kundry_Wag
Bike: Oh, I see. If I understand correctly, the function definition (defn) could be a macro that would replace the built-in `assoc` to a different version of it
21:21:38
Bike
relatedly, given that clojure is actually making a new map, the assoc call isn't actually violating the restriction
21:23:44
Bike
you'd want to define a-function's return type, or use something like lisp's THE to type the value
21:30:24
Kundry_Wag
Bike: That's covered by Schema (in Clojure). I didn't know CL had a built-in way to do that, though
21:33:35
Bike
and to be quite honest, rather than having 'alist but restricted to using these keys', i'd probably rather have a class
21:35:03
Bike
type stuff gets much easier if you restrict the possible restrictions to be easy stuff like that