freenode/#lisp - IRC Chatlog
Search
3:58:46
aeth
What do people use for Lisp testing? I've seen two. Roswell. And now this lisp-devel Docker. https://lispcookbook.github.io/cl-cookbook/testing.html#gitlab-ci https://hub.docker.com/r/daewok/lisp-devel/
4:09:40
edgar-rft
aeth: there's an ANSI test suite for testing Lisp, but I assume that you're not looking what you're asking for.
5:03:34
low_brain_cache
I haven't registered a nick but I've been on here as beginner_supreme, cl0s, Common_Lisp (I think), etc.
5:06:37
low_brain_cache
I figure that since nicks are temporary assuming low activity, and registering a nick doesn't necessarily disallow others from using it, there's no reason to register
5:13:32
LdBeth
I believe freenode also allow to register several different nick under one mail address for bot or something
5:14:47
low_brain_cache
Is there a freenode manual of commands? /help lists a table but /help <command> doesn't do anything. <- Sorry for the non-lisp question but since we're on the topic of IRC... ;)
5:19:47
LdBeth
low_brain_cache: many commands are IRC client specific, so you should find your own manual
7:40:07
kuribas
Hi, I've set inferior-lisp-program with customize to sbcl, however everytime I restart emacs, it gets reset to lisp. Any idea why?
7:42:59
hajovonta
kuribas: I think this is an #emacs question, but I think you should set the state to "Save for future sessions"
8:23:33
jdz
I have no idea. Defining questions in terms of what Haskell does in #lisp seems... wrong.
8:30:34
jdz
Lisp is not Haskell, so this most likely is not the best way to solve whatever problem it is you're solving.
8:38:09
loke
No one will every convince me that reverse drop reverse is simple or beautiful. With a magic compiler is may be efficient. Maybe.
8:39:50
lieven
the standard prelude has some awkward stuff in it. for real work, you should use Text for strings
8:43:43
kuribas
I was reading this, and I found the lisp code quite ugly: https://markkarpov.com/post/lisp-and-haskell.html
8:47:38
kuribas
in haskell: addPadding str pad newline = intercalate ('\n' : replicate pad ' ') $ lines $ if newline then "\n" ++ str else str
8:49:08
hajovonta
Common Lisp is not a functional language, but it supports functional style programming.
8:50:52
jdz
I wonder why people who have no real experience with a programming language immediately have an urge to write articles titled "Why XXX is not my favourite programming language and why you should use YYY."?
8:53:42
hajovonta
loke I think (judging by the name) it takes a string and extends it with dummy characters or something like that
8:53:46
loke
shrdlu68: Did you see the add-text-padding fuction? Wtf... w-o-t-s with a map 'string inside followed by a return that is never used?
8:54:41
loke
Oh wait. he maps over the characters. And he seems to believe that 'string refers to the type of the thing he's mapping over
9:01:35
jdz
Never mind that the original code has parameter named STR that is shadowed by LET binding.
9:03:09
jdz
OK, that's intended. Making a copy of input for no apparent reason. I wonder if the guy has tested his code?
9:03:11
loke
I like his argument that QL doesn't use tests. But tests are required. Therefore QL is broken.
9:03:27
loke
Instead of: QL doesn't need tests, and still works. Perhaps I'm wrong and tests are not the end-all-be-all?
9:03:54
jdz
This function seems so convoluted it triggers all the possible wrong signals in my brain.
9:04:19
loke
jdz: It probably _has_ tests, and therefore it's perfect. No matter hopw convoluted. The tests pass!
9:04:55
kuribas
ok, so I have this, with the cl-string library: (join ((concat (string #\Newline) (repeat padding " "))) (lines str))
9:12:40
jdz
I have real trouble wrapping my head around what it's supposed to do and in what circumstances one would use such a function.
9:20:11
jdz
Elegance is subjective. I personally find my version straight-forward and directly matching the problem statement, and also not particularly inefficient.
9:25:37
varjag
kuribas: idiomatic lisp solution is to use an existing library, implementing this efficiently
9:43:43
jdz
Also, my version is easy to change so that it writes straight to a stream, without accumulating all the strings which most likely go to a stream afterwards, anyway.
9:44:08
jdz
kuribas: I recently heard that in Haskell it's also OK to mutate things if they don't escape a function?
9:45:31
shrdlu68
Called with exactly the same set of arguments, the result with always be the same, regardless of any changes outside the function.
9:46:50
jdz
shrdlu68: No, bragging about one's favourite compiler is the whole point of immutability.
10:02:19
LdBeth
shka: monads are not Haskell specific thing. Any languages with proper lambda support can have that
10:08:04
LdBeth
A CLOS question, now I have a class which has slots shared across all instances by :allocation :class, but how can I access these slots given I only have name of that class with no instance
10:20:24
flip214
Can anybody remember seeing a high-level interface to the Ethereum Blockchain RPC in CL?
10:37:18
Ukari
i found that in some project's file structure, test module are put into /t instead of /test, is it a tradition? for example, https://tinyurl.com/ya7f5w95
10:55:58
kuribas
since we were talking about efficiency... I am disassembling a simple function: (defun f (x y) (+ x (* y 2))) in sbcl. The resulting code doesn't have any add instruction...
10:56:25
kuribas
I tried adding a declaration: (defun f (x y) (declare (type fixnum x y)) (+ x (* y 2)))
11:00:58
kuribas
I would think it does a check first on the type, then generates efficient assembly to add the two numbers.
11:02:24
scymtym_
kuribas: (* <fixnum> 2) is not a fixnum. try e.g. (declare (type (unsigned-byte 32) x y))
11:08:11
scymtym_
if you want modular arithmetic instead of restricting the argument types, you can do (defun f (x y) (declare (type fixnum x y)) (ldb (byte 32 0) (+ x (* y 2)))) (in SBCL)
11:12:47
scymtym_
TMA: it would produce the correct result. efficiency would depend on whether the untagged representation was used for the arithmetic, i think
11:14:08
lieven
if you want to assure the compiler that that wont happen you can do (the fixnum (* <fixnum> 2))
11:17:52
lieven
kuribas: in optimising settings, a CL compiler will not check your type declarations but will take your word for it. If you lie to the compiler, it will have its revenge.
11:23:25
jmercouris
I'm just trying to dispel the myth ath CPU cycles are ALWAYS cheap, there is of course times when they are cheap, like during one-off tasks
11:25:11
kuribas
you can count the cost of requiring more computers - the cost of the programmer optimizing it.
11:26:54
jackdaniel
can I buy 20 CPU cycles from aws? that's really fine-grained :) what if I have a program which is composed only of operations where each takes 3 cycles?
11:27:23
kuribas
having to choose between safety and efficiency is also something you get when you bargain for using a dynamic language
11:28:48
jackdaniel
I don't think the major efficiency and safety gain comes from the language you write in – you can create unsafe and inefficient algorithms in a safe and efficient language
11:30:08
jackdaniel
kuribas: you simply write safe and efficient code ;-) what lisp gives you is a decent optimizing compiler and runtime safety guarantees
11:31:50
jdz
kuribas: make sure you use the takeWhile, etc. version (i.e., tho generic programmer-cycles saving one).
11:35:16
jdz
_death: c'mon bruh, we only care about toy examples, not practical real world scenarios.
11:44:28
jackdaniel
if the type is inferred, then redundant type checks may be safely removed (unless there is a bug in type inference algorithm)
11:45:26
White_Flame
in other words, type checks internal to a function body migh tbe elided. Those at the interface should remain intact
11:48:29
kuribas
what I mean, is that if you have a function using fixnum, calling another function with fixnum, the typecheck is redundant
11:51:49
jdz
It looks like you're wasting programmer-cycles with unimportant details instead of concentrating on a task at hand.
11:53:10
jdz
I trust my programs to be efficient enough if I don't write intentionally inefficient code.
11:53:22
_death
think about program evolution.. starting a lisp brings up a world at a particular stage of evolution, and you further evolve it by evaluating code.. static languages result in a dead world that's incapable of evolution
11:55:23
kuribas
so the lisp code took 0.069 (with no optimizations as recommended), the haskell code 0.009sec
11:55:32
_death
jmercouris: perhaps a better way to distinguish is system thinking vs. language thinking
11:56:19
jackdaniel
kuribas: then stick to haskell if you plan to write these kind of programs and you really care about efficiency on such level, lisp clearly fails to meet your standards
11:58:53
_death
jmercouris: http://dreamsongs.com/Files/Incommensurability.pdf contains some good discussion about systems vs. languages.. it takes a while to get there though, because the author wrote one essay where he should've written two
11:59:07
jdz
Right, and write another article titled "Why Common Lisp is not my favourite programming language and why I'm sticking with Haskell".
12:01:27
jackdaniel
protip: you may put x as a third argument in dotimes, it will be returned by that block
12:03:54
jackdaniel
kuribas: may I ask a question: do you plan to learn lisp, or your goal is to compare it to haskell?
12:04:42
jmercouris
jackdaniel: may I ask a question: why do people preface questions with questions in this manner?
12:05:13
jackdaniel
imo you can't do both *at the same time*, because these are two different languages with different promises
12:05:38
jdz
kuribas: you might as well think what you're doing. Why not set -O0 -g for haskell version?
12:05:38
jackdaniel
for instance (I don't know haskell, so I may be wrong here) – if haskell is functional, then it can memoize function call results
12:05:55
jackdaniel
in Common Lisp you'd have to create your own defmemo macro for that to achieve similar result
12:06:40
jackdaniel
jmercouris: how can I answer? that's how I speak sometimes? should I really explain myself on this matter?
12:07:14
jmercouris
jackdaniel: I was making an observation that I thought you might be interested in reflecting on
12:08:23
kuribas
jdz: I am getting the same performance with speed 3, but maybe i am doing something wrong.
12:09:04
jmercouris
jackdaniel: https://en.wikipedia.org/wiki/Socratic_questioning - last post on the matter, as it is off,topic
12:12:00
shrdlu68
kuribas: The biggest optimization, in my experience, is usually in type declarations.
12:15:18
jdz
Also, this exercise is really silly, nothing to do with the ADD-TEXT-PADDING we discussed earlier.
12:19:38
jdz
I thought the point of the exercise was not to try and optimize a trivial piece of code, but to compare the speed of idiomatically written code...
12:23:52
jdz
Considering you've translated the code correctly, and Int in Haskell is 32-bit signed integer.
12:29:12
jdz
Next step of the exercise is to measure the time it takes to compute a value that exceeds Haskells Int type.
12:37:49
jdz
kuribas: I'd still like to know what the result with my proposed change for the Haskell version is.
12:39:19
shrdlu68
kuribas: Indeed. But you don't have to, until speed really matters. It won't get in your way screaming for declarations and types.
12:39:58
kuribas
shrdlu68: I am going to work on a codebase involving lots of data, were performance does matter.
12:40:49
shrdlu68
kuribas: Good, write the code as you would naturally, with optimal data structures and algorithms, _then_ add declarations.
12:43:05
jmercouris
jdz: If you reframe any problem enough times, I belive you'll always end up where you started: rewrite it in rust
12:43:38
kuribas
White_Flame: for example, simple averaging numbers is faster on the CPU, because you don't have the latency of transferring to the GPU.
12:44:24
jackdaniel
xificurC: I have my doubts, but not sure who should take a kick, it seems like a rebellion ;-)
12:44:57
jdz
We just proved the superiority of Common Lisp over Haskell, surely we can have a little afterparty, right?
12:45:48
shrdlu68
There has been a renewed interest in comparing languages recently, what with all the new languages being invented, and all the propaganda being thrown around.
12:45:57
jmercouris
we can only compare the specific implementation of a problem in language A and language B
12:46:29
jackdaniel
there is no such thing as language speed. quality of produced code may be measured, or at the very last – language "optimization"-friendliness
12:47:39
jmercouris
I was even having a conversation with beach at the time where I could not explain it to him
12:47:55
jdz
This what it was all about: <kuribas> the thing is, I don't find giving up safety for performance a good option.
12:48:36
jmercouris
it wasn't for a lack of his comprehension or anything, I just couldn't put the thoughts into words, in that context
12:53:29
_death
typical development in lisp is working with a living system.. you define stuff, test in the repl, redefine, inspect objects, etc. typical development in haskell is write, compile, rinse, repeat.. each time setup the whole thing from scratch
12:56:06
White_Flame
and lisp refactoring teaches you to keep your abstractions well-defined so you can adjust things later. I wonder how difficult it is to refactor the types in a haskell program
13:08:59
runixy
Can I specify some constraints on the type of the parameters for a function, such as informing the compiler that the parameters are NUMBER? See lines 75 to 113 (including error message) on https://paste.ofcode.org/yzZkqCsTshQZtJ5gKwKddM as I would like to avoid having to use the macro for defining the function.
13:14:42
beach
runixy: I am not sure I understand what you are trying to do and I am not sure I understand why wall-builder-not-working is not working.
13:19:16
xificurC
I'm pretty sure runixy is going through this https://chriskohlhepp.wordpress.com/reasoning-systems/specification-driven-programming-in-common-lisp/
13:20:44
runixy
yes, and then I don't understand why I/we would have to make a macro to build the wall-builder function
13:23:23
beach
runixy: If you declared it to be a number you would lie to the compiler, because you are passing a symbol, not a number.
13:26:13
beach
runixy: Can you please tell us whether build-constraints is supposed to have any side effects. It looks to me like it is just supposed to return some code. Right?
13:29:19
beach
So if BUILD-CONSTRAINTS returns something useful without having any side effects, in this context, the useful thing is thrown away.
13:29:34
xificurC
beach: build-constraints returns (progn (setf ...) (setf ...)) as seen from his paste
13:31:01
runixy
ye, and then I don't understand why he had to wrap the wall-builder function in a macro
13:31:48
runixy
the macros are used to provide forms that are being evaluated in wall-builder-builder
13:33:18
xificurC
runixy: this is explained in the blog post. The guy writes out a function for 2x2 and one for 3x3. Then he proceeds to write a macro which takes the dimensions as parameters and produces the boilerplate code automatically
13:34:50
xificurC
runixy: what might be tripping you is that the macro always generates (defun wall-builder ...) which isn't really correct. It should generate a different function for each input, e.g. wall-builder-2x2, wall-builder-4x20, ... The author just didn't bother to write this out explicitly
13:34:53
runixy
ye, but couldn't wall-builder be a function taking in the parameters directly (if I could specify types)
13:35:31
beach
runixy: I think you will understand if you macroexpand the call to wall-builder-builder.
13:35:32
xificurC
runixy: it's not about types, forget types. It's about having a solver for a 2x2 grid, a solver for a 20x20 grid, whatever one wants
13:36:34
xificurC
runixy: he wrote out the 3x3 case, did you see how much more boilerplate code that was? Now he wrote a macro so if he needs a 4x4 solver the macro will generate a solver for it. It should be named wall-builder-4x4 though, not overwriting any previous wall-builder
13:37:14
runixy
I have to redefine wall-builder (by using wall-builder-builder) for different parameters, but I was curious if that can be circumvented and just define a function that then evaluates the other macros at run-time.
13:38:16
beach
runixy: If you did that, you would see that the BUILD-CONSTRAINTS form has numbers in it.
13:39:05
runixy
I don't get why doing a macro to define a function is able to look past type issues, when just defining the function is not? I guess that is my real question
13:40:33
beach
If you declare the type to be number, then you will like to the compiler because you are passing it symbols, not numbers.
13:44:39
xificurC
(defmacro add-one (x) `(+ ,x 1)) (let ((n 1)) (add-one n)) . this is a simplified version of his issue, correct beach?
13:46:38
beach
makomo: When the compiler sees the call to build-constraints, it will macroexpand it.
13:48:14
beach
makomo: Macros don't evaluate their parameters, so you can't pass it a symbol expecting its value to be used.
13:48:45
makomo
beach: yes, of course. which means that the macro expects to work with constants, correct?
13:51:31
specbot
Congruent Lambda-lists for all Methods of a Generic Function: http://www.lispworks.com/reference/HyperSpec/Body/07_fd.htm
13:51:57
beach
xificurC: More like (defmacro add-one (x) (1+ x)) and then the difference between (add-one 234) and (let ((n 234)) (add-one n))
13:53:24
makomo
yup, same. so then what would be the reason for the method accept invalid keyword arguments?
13:54:24
makomo
i mean, i don't know whether to interpret that last sentence in case 4 as something that's applicable only when case 4 applies, or as a general fact (with or without case 4)
13:55:04
makomo
so i have (defgeneric hello (a b &rest c)) and (defmethod hello (a b &key c)). then i call (hello 1 2 :d 100)
13:55:08
beach
I think case 4 is all about &key being mentioned in the generic function lambda list.
13:55:47
xificurC
runixy: try (defmacro what-am-i-at-compile-time (x) (format t "type ~a with value ~a~%" (type-of x) x)) and then (what-am-i-at-compile-time 100) and (let ((x 100)) (what-am-i-at-compile-time x))
13:56:38
beach
makomo: Do we know that an implementation is obliged to signal an error in such a situation?
13:57:40
specbot
Unrecognized Keyword Arguments: http://www.lispworks.com/reference/HyperSpec/Body/03_ead.htm
14:26:31
beach
_death: Can you point to the relevant Common Lisp HyperSpec section that supports that claim?
14:28:57
beach
That if the generic function lambda list mentions &rest but not &key, then there is never any argument mismatch, even when a key is passed to a method that does not accept it.
14:31:00
makomo
if the answer is "because only the generic function checks the argument list, not the methods", then where is this said in the standard?
14:31:58
makomo
this is valid, why? the method clearly takes only the keyword argument :c. why is :d allowed?
14:33:55
makomo
i.e. you're calling the generic function, and only it does the validation of the arguments
14:35:00
_death
if it took &key, then there'd be validation.. perhaps also when the method is called
14:35:50
beach
_death: Like makomo, I don't buy your argument. You may be right, of course, but I don't see it.
14:37:45
Inline
beach: i have an offline question related to wxmaxima, maxima therein is loosing it's socket somehow, when i start maxima from the console everything works as expected....
15:04:42
jackdaniel
I don't remember details, but we were troubleshooting this problem with someone using maxima