libera/#commonlisp - IRC Chatlog
Search
3:45:03
jcowan
I understand why not: if you are allowed to add methods to EQUALP, you break its contract.
3:45:06
beach
Not that large actually. Currently, the bootstrapping code consists of around 4kLOC, including a GUI-based backtrace inspector.
3:46:52
beach
And the bootstrapping code contains a lot of duplication that we will eventually get rid of.
3:54:07
jeosol
@beach: Great list of things that have been implemented. This will help the language see some resurgence in some fashion given it could be a good general base for the other implementations (with time) and development efforts can be pushed in other directions
3:54:51
jcowan
As an example, NUMBERP's signature is "numberp object => generalized-boolean". You don't want to permit a method on it that maps pairs to T, or worse yet to "What, me worry?"
3:55:07
jcowan
so anything with that signature or a related signature needs to be considered for sealing.
3:55:33
beach
jeosol: Thanks. Yes, I think I need to make the bootstrapping technique applicable to other implementations.
3:58:15
Bike
nothing. that's my interpretation of "you have to seal every function from T to generalized-boolean"
3:58:35
Bike
like, "for every function with an argument of type T and return value of type generalized boolean, that function must be sealed"
3:59:04
jcowan
On the other hand, if you want to add classes that actually represent numbers (quaternions, Gaussian integers, etc.) you may indeed want to unseal NUMBERP to include them.
4:00:13
Bike
several have extended sequences, but i dunno if there are ones with other stuff like that
4:01:54
Bike
but on the other hand if you could do that it might screw up safety, which you don't want
4:02:03
Bike
like if a compiler definition gets out of sync with the actual runtime definition or something
8:13:51
flip214
Help, please. What's the difference between these forms? (intersection r l) (remove-if-not (lambda (l) (member l r)) l)
8:14:14
flip214
r and l are lists of structures; the first form returns the expected 10 results, the second only 6 values.
8:43:38
pjb
(let ((r '(1 2 3 4 1 2 3)) (l '(3 4 5 6 4 5))) (values (intersection r l) (remove-if-not (lambda (l) (member l r)) l))) #| --> (3 4 3) ; (3 4 4) |#
8:44:56
pjb
What is missing is only (defun seq-equal (a b) (and (subsetp a b) (subsetp b a))) ; perhaps more efficiently.
8:44:58
gin
Need some advice with this code: https://plaster.tymoon.eu/view/2558 - I am comparing two approaches here. (1) ex-1: A single LET for all lexical variables. (2) ex-2: Multiple nested LETs for defining lexical variables only where they are needed.
8:45:39
pjb
a set-equal function would make it more concrete that there's a set type based on list, like subst and copy-tree make it clear there's a tree type based on lists.
8:47:07
gin
pjb: If I assume compiler can optimize things out, then I can stick with ex-1 where a single LET contains all lexical variables, couldn't I?
8:47:55
beach
gin: It is not a question of compiler optimizations. It is a matter of how much code the person reading your code has to consider for an occurrence of the variable.
8:47:57
gin
beach: thanks! I was thinking that too. But then does it bother anyone that it may lead to multiple nested-LETs making the code harder to parse with eyes? Or is that not a valid concern?
8:52:28
gin
beach: thanks! I have mentioned in comments at the top that I am making a contrived example to compare my LET-approaches. could not make a more sensible example. I understand that LOOP COLLECT is appropriate here and COUNT is not required.
8:54:04
_death
gin: the nested LETs make it easier to pull the forms out into their own function, for example.. they also make it easier for the reader to know the value of the bindings, considering the alternative is a variable that changes over time
8:54:26
beach
(loop for article in articles for newline-position = (position #\Newline article) collect (subseq article 0 newline-position)) with appropriate newlines inserted.
8:57:34
beach
gin: A general rule of programming is that a function should do one single thing. The computation of the length makes the function do two things, which is not good.
8:58:26
beach
gin: You might see that more easily if you consider this function as also computing the reverse of the list, the Fibonacci number of the length, etc.
9:05:08
beach
So you must already know those rules, i.e., minimize the scope to make life easier for the person reading your code, and make each function do one thing.
9:31:40
gin
thanks shka. Is that true in general too? does it take constant time for any proper sequence?
9:34:01
beach
gin: If you think about how lists are represented, you can see that it has to traverse every CONS cell as shka is saying, so there is no way it can be O(1).
9:36:39
beach
gin: And if you don't know how lists are represented, it is time to learn that part. Otherwise, may things will likely confuse you in the future.
9:38:06
beach
... like why (defun push-it (element list) (push element list)) won't "work" as expected.
9:40:04
beach
shka: Indeed. But a significant number of newbies here don't seem to find it useful to read about things like that.