freenode/#lisp - IRC Chatlog
Search
2:54:17
didi
Is there a straighter way of changing the cdr of each cons of a list of cons than: (mapcar (lambda (x) (cons (car x) (change (cdr x)))) list-of-cons) ?
3:03:19
didi
|3b|: I still want a new list. I just don't want to call (cons (car x) ...). I want to only change the cdr of conses.
3:03:21
|3b|
if CHANGE is a function, or you don't want to modify structure of input lists, then probably not
3:31:52
pjb
didi: clhs 3.6 For list traversal operations, the cdr chain of the list is not allowed to be destructively modified.
3:32:28
pjb
didi: this doesn't prevent you to implement your own iteration, mutating the cdr as you want. But you have to think about what you are doing!
3:48:26
pjb
(let ((loc (acons :o 1 (acons :t 2 (acons :t 3 nil))))) (dolist (cons loc loc) (setf (cdr cons) 0))) #| --> ((:o . 0) (:t . 0) (:t . 0)) |#
3:49:24
pjb
Now, if you insist on a HOF, use mapc: (let ((loc (acons :o 1 (acons :t 2 (acons :t 3 nil))))) (mapc (lambda (cons) (setf (cdr cons) 0)) loc)) #| --> ((:o . 0) (:t . 0) (:t . 0)) |#
4:23:28
beach
You need to remind me of this. I am working on the CST-to-AST system, and I am notorious for having a hard time switching between different tasks.
4:25:17
pillton
Well, template-function and its relative specialization-store, are for solving problems similar to the problems you faced when implementing the CL sequence protocol.
4:26:10
stylewarning
pillton: did you see this kooky thing I wrote a few years ago? https://bitbucket.org/tarballs_are_good/parameterized-function
4:26:48
stylewarning
I don't think what I wrote is exactly matching the vision of what I wanted to write. But it worked ok enough for an efficient Lisp matrix library, even if the calling convention was verbose
4:32:59
pillton
stylewarning: This is an example: https://github.com/markcox80/specialization-store/blob/master/tests/standard-store-syntax-layer.lisp#L20
4:35:14
pillton
It will work with declarations provided your implementation is supported in Bike's introspect-environment system.
4:41:01
stylewarning
I want to help out with initiatives to make high level efficient code easier to write in Lisp
4:42:07
Zhivago
I used to think that type based dispatch was a good idea, and then I realized that it's only really useful if your function doesn't have coherent semantics.
4:43:39
stylewarning
My problem is usually just specializing functions for all different manner numbers, like single and double floats
4:45:03
pillton
Zhivago: One of the premises is that it doesn't matter which specialization is executed.
4:45:41
Zhivago
pillton: Right, in which case you might as well dispatch off the representational decision.
4:46:19
Zhivago
pillton: It's just that CL doesn't expose fixnum, bignum, single-float, etc as classes.
4:48:46
stylewarning
Replacing an IF with some spectacular function dispatch mechanism requires good justification in my opinion, at least if I have my code reviewer hat on
4:49:14
Zhivago
I think that defining functions with discontinuities isn't too terrible using some kind of pattern matching, but it doesn't feel like it's really the right thing to be trying to do in terms of type.
4:50:58
pillton
You are comparing apples and oranges. Specializations are independently extensible. COND is not.
4:51:34
Zhivago
Sure, but does it make sense to independently extend a function in terms of semantic discontinuty?
4:52:33
pillton
Which is why one of the premises is that each specialization performs the "same" task.
4:53:48
pillton
This premise avoids the problem you find yourself in when dispatching on types that do not form a tree.
5:01:52
pillton
Maybe if you provided me with an example I could implement it for you and put it on the wiki?
5:31:53
jack_rabbit
"prog2 evaluates first-form, then second-form, and then forms, yielding as its only value the primary value yielded by first-form."
5:33:04
jack_rabbit
The maintainer has not been persuaded to update? Or is this a mistake in the official spec as well?
5:34:28
jack_rabbit
So technically... are common-lisps that do the expected thing non-conforming, then?
5:36:23
beach
jack_rabbit: The Common Lisp HyperSpec is a very good document as standards go. But there are still a significant number of errors in it. Not to mention numerous situations that are undefined or that have unpredictable results.
5:37:44
jasom
there was debate as to whether or not a vector of type nil should be treated as a string (which a strict following of the hyperspec would require), but I think that one implementions decided to actually follow the spec as written
5:41:48
|3b|
ACTION thought it was more that you had to be able to specialize arrays on NIL (and the result is a string), because it is also a subtype of bit
5:49:47
|3b|
right, which is why you can't upgrade NIL to any other type, since there are 2 disjoint required specialized types (CHARACTER and BIT) so it can't upgrade to either
5:50:30
beach
A string is a specialized vector whose elements are of type character or a subtype of type character.
5:51:39
beach
Since NIL is a subtype of type character, a vector whose elements are of type NIL is a string.
5:55:59
loke
beach: Fair enough, but you have to admit that it's very unlikely that this was actually considered during the spec design.
5:56:53
|3b|
yeah, i suspect most implementations don't bother implementing arrays of type NIL in the first place
5:57:39
loke
ACTION thinks the spec should be implemented _exactly_ as written. No exceptions... (hold my beer while I submit a patch to fix the implementation PROG2
5:58:46
|3b|
(upgraded-array-element-type 'nil)=>T on (old version of) ccl here, so (make-array 0 :element-type nil) => #() instead of ""
5:59:59
|3b|
loke: don't forget to leave the limits at the lowest allowed values, like array-dimension-limit = 1024 :)
6:00:43
beach
loke: If you want to implement prog2 that way, I suggest you also erase the hard disk if AREF is given an object that is not an array.
6:02:37
loke
ACTION was about to suggest somethign silly with reagrds to charcter-fonts, but I now realise that that was dropped in CL
6:02:39
beach
loke: I didn't look at SVREF, but AREF takes an array, and the general rule is that the behavior is unspecified if that kind of restriction is violated.
6:03:44
loke
beach: Yes. I guess you're right... I was thinking that SVREF had some special provisions for that, but it appears that CL doesn't say anything about wrong types being bassed to any functions.
6:04:14
loke
Anyway, in CLtL2, a characer can have a "font" property. That property is just an integer.
6:04:59
jack_rabbit
I'm not too familiar with the ANSI organization, so it's possible this question includes some incorrect assumptions. I know that committes for lanugages like C release a new standard for their languages every decade or so, but Common Lisp seems not to have. What is the status of the Common Lisp standard committee?
6:07:19
jack_rabbit
That was my next question. :) But there must be people at ANSI who determine the legitimacy of such a committee, no?
6:08:09
beach
I mean, "yes", in that ANSI can refuse to make such a committee an official ANSI committee.
6:08:13
jack_rabbit
For instance, if I *did* set up such a committee, my standard would likely be a total disaster. Could I still push that through as CLtL3?
6:08:31
loke
Different standard organisations have different rules as well... ANSI is just the US standars body. Every countr has their own, and then there other other, global standards bodies like ISO or IEEE.
6:09:52
jack_rabbit
Ok. So it is democratized it the sense that its success or failure would largely depend on who, if anyone, actually used/implemented it.
6:15:03
loke
Have they come up with anything useful, ever? (except CORBA, which was useful for a moment in history)
9:06:35
mfiano
Does anyone know why Emacs/paredit insists on indenting the documentation strings of these two defgeneric forms differently on M-q? The second paragraphs are inconsistent. https://files.lispcoder.net/images/screenshots/img-20170918045634.png
9:08:16
jackdaniel
mfiano: it is not paredit but emacs, if you indent two first lines of the paragraph to the left, then the rest will follow
9:09:51
loke
mfiano: It should leave the string alone, unless you are inside the string when typing M-q
9:10:31
jackdaniel
try removinng two spaces before functionality in first docstring and do M-q after that (still havinng cursor in docstring)
9:11:02
mfiano
Yes, I am. I would like the string to be justified consistently. I am wondering what is causing that outdenting of the first line of the second paragraph in the first form.
9:11:51
jackdaniel
I'd say initial shape of docstring, not defgeneric or anything else causes different wrapping