freenode/#lisp - IRC Chatlog
Search
21:54:46
aeth
I think there's another emacs minor-mode that is more general (i.e. doing more substitutions, not just lambda), but of course that might have more edge cases that will mess up formatting. lambda just has that one (very rare) edge case.
21:56:12
aeth
Well, that's "short lambda" in the literal sense of shortening "lambda". There are other possible short lambdas, like (lambda (x y z) ...) into #[x y z : ...] or something, or maybe (lambda (x) ...) into #[...] where x is now an implicit _
21:57:48
aeth
Of course, substituting "lambda" for "λ" (in several ways, including in the source code or locally in Emacs) gets you most of the way in terms of conciseness, especially once you take into account the extra # most reader macros will add.
21:59:56
aeth
Especially since lambdas are almost always one-liners, or with a newline after the lambda-list (not in the middle of it) so it doesn't affect formatting
22:00:09
mgsk
I suppose it's one of those things that seems nice in theory, and when you have a tonne of throw-away lambdas scattered around. But in practice, it doesn't save you much.
22:02:55
aeth
mgsk: yes, but that should be #λ not λ imo. So now you have #λ(+ _ _) vs. (λ (_) (+ _ _)) and you don't gain much at all and it's super-niche.
22:03:33
madand
Hi all. For 1- or 2-argument lambdas have a look at https://github.com/vseloved/rutils/blob/master/docs/tutorial.md#user-content-readtables
22:03:40
aeth
and really imo it should be #λ((+ _ _)) because most lambda bodies aren't going to be just one expression (usually you can just use #'+ directly if you're in that situation)
22:03:52
Oladon_work
moldybits: And it's not like you're substituting some random character (*coughRubycough*); λ _is_ Lambda.
22:15:33
aeth
Some Lispers don't like the few symbols that are used, like +, *, /, and -, but those are probably justifiable because they're more familiar than the letters and they're easy to type.
22:17:02
aeth
iirc, early Lisp didn't really use any symbols in the identifier names, which is why we have string= for case-sensitive string equality and string-equal for case-insensitive. Backwards compatibility! The old way was case-insensitive and its name remains
22:17:26
aeth
and then you have Scheme which sort of embraces symbols more, which is how you get ? and !
22:25:54
aeth
I'm surprised it wasn't INC and DEC, since they probably already had INCF and DECF at that point
22:26:34
pjb
mgsk: why do you want a package? (set-macro-character #\λ (lambda (s c) (declare (ignore s)) `(cl:lambda ,(read s) ,(read s)))) (mapcar λ (x) (* 2 x) '(1 2 3)) #| --> (2 4 6) |#
22:33:16
aeth
(Yes, that's a joke based on all of those "What is Lisp?" debates that the Internet loves to have.)
0:04:28
eigenhombre
I finally figured out my `cffl` problems; posted solution here: https://stackoverflow.com/a/57931463/611752. The problem seems to have been a bunch of outdated Homebrew packages.
0:09:47
pjb
eigenhombre: that's one problem of cffi (and ffi in general): they use a static definition of foreign objects that is generally taken from C header sources (tripple whammy!).
0:10:32
pjb
eigenhombre: at least, ccl tries to go thru ffigen to use a definition database, but ffigen is bitrotten, so it's not easy to generate new ffigen databases for random libraries.
0:11:39
pjb
eigenhombre: in any case, the only «"'reasonable'"» approach would be to retrieve the foreign object definitions from the DWARF debug info, but it's not often available in any case.
0:14:54
eigenhombre
pjb: Thanks! I would prefer not to use FFI at all but want `curses` or equivalent... any other approaches I should look at?
0:22:26
no-defun-allowed
for integration, "symbolic" would be going from x^2 to x^3/3, "numeric" would be going from x^2 from 0 to 1 to 1/3, one works with numbers, and the other just symbols
0:22:50
pjb
eigenhombre: eg. solving x^2+2x+1=0 numerically may give you -1.00001 and -0.999999 numerically and -1 and -1 (the integers) symbolically.
0:24:00
no-defun-allowed
(if you had a better integral that converged, eg 1/x, you could integrate from -∞ to ∞)
0:25:18
pjb
eigenhombre: using cl-charm thru FFI should be ok once you get it working. The difficulty here is the termcap or terminfo database, which is arcane. In this modern world, we could implement a terminfo database reader, and then use the control code obtained to issue them ourselves in a curses package written purely in lisp. It is difficult to do it conformingly because this requires binary I/O on the terminal, which is not defi
0:26:12
pjb
eigenhombre: so there's no really good solution. A good solution would involve writing a CDR to specify binary I/O on unix tty and windows console terminals, and to use it to implement the above pure lisp curses.
0:27:14
eigenhombre
pjb: Maybe a little more ambitious than my use case to start with, which is implementing a roguelike :-) But that's interesting, thank you!
0:27:16
pjb
eigenhombre: this would also involve parsing and understanding the C curses code, in which I expect a lot of special cases and terminal specific heuristics to be encoded. Ie. the knowledge of how to use the terminfo database.
0:27:51
pjb
eigenhombre: yes, but that's one problem: everybody wants to use ncurses for a little program, so nobody improves the lisp ecosystem.
0:28:31
eigenhombre
It sounds though like it's not only a lisp ecosystem issue -- I know curses is like 40 years old or something....
0:28:34
pjb
This is where you would need to win the lotto or sell a multi-hundred-millions startup, to finance such (usele$$) lisp developments.
0:29:12
pjb
eigenhombre: The thing is that people still may use 50 years old terminals of various kinds.
0:31:59
pjb
and run on linux CL programs that will have their *terminal-io* connected to such devices.
0:32:39
pjb
eigenhombre: it's also not entirely geeky; some professionnal environment still use such old devices for various good-enough reasons.
0:34:50
pjb
OR, you can throw all that away, and design a new package for 2D textual interfaces. You might base it on emacs, or on some specific terminal emulator (but a lot of people would question you supporting a specific one such as Linux; perhaps using ECMA-048 would be ok, but not all terminal emulators support all the ECMA-048 features (hence back to terminfo)).
0:35:51
pjb
wyse terminals were nice too: https://www.ebay.com/itm/Refurbished-Amber-Screen-Wyse-55-Terminal-901237-07-WY-55-with-PCE-Keyboard/292313662783?epid=669517948&hash=item440f40853f:g:rNcAAOxy7nNTSXla
0:37:22
pjb
anyways, nowadays most end-users will be behind a mobile web browser or a ms-windows box. So perhaps you only need to support that.
0:39:08
pjb
Or just wait for AI singurlarity; this will solve all those problems for us once and for all.
1:49:17
aeth
Josh_2: Symbolic math is roughly what you learned in school, with a handful of exceptions like Euler's method (if you learned that in school... or maybe quite a few more exceptions if you e.g. specifically took a numerical class in the math or comp sci department at a university).
1:50:46
aeth
So e.g. symbolic integration is applying a big series of rules to attempt to reverse integration, including ones you'd learn in Calculus II and ones that are far too complicated for anyone but a computer to do.
1:51:15
aeth
And numerical integration looks like this: https://en.wikipedia.org/wiki/Numerical_integration#Adaptive_algorithms
1:52:50
aeth
As a rule of thumb, never write your own algorithms in this domain, just apply what you read on Wikipedia or in a book.
1:53:21
emma
what are some reasons that we still enjoy lisp and would like to use it instead of some alternative
1:55:32
verisimilitude
I like the machine independence, the ability to be lazy through metaprogramming, and how Lisp is particularly suited to programs that are vague in every way as they're being written.
1:56:16
aeth
emma: My elevator pitch for Lisps is always syntactic representations of languages rather than using text-based templates. HTML is far from the only thing you can do this with (see: CSS, JS, SQL, GLSL, JSON, XML, CSV, etc.), but it's probably the simplest example.
1:57:23
aeth
emma: In mainstream languages you'd use a template system like this to embed logic within .html files that then get processed textually to do your substitutions. <html> ... <body> <p> Hello, {{username}}! </p> </body> </html> might be what it looks like using something like https://mustache.github.io/
1:58:36
aeth
emma: In a Lisp, you'd be more likely to do something like this: `(:html ... (:body (:p "Hello, " ,username "!"))) and generate the final HTML string at the end, after working on it structurally, perhaps in functions or perhaps in macros (or both!)
1:59:09
aeth
So you get the full language, without the mess of having to embed it (and possibly escape certain characters) or using some DSL or something else.
1:59:45
aeth
And it's not much, I wrote something to generate HTML in a few days, with this test generation: https://gitlab.com/snippets/1892940#L83-115
2:03:04
aeth
I was thinking about how I'd do the same thing in C++ and it's not pretty. First, I'd have to make a gigantic enum of all of the tags instead of just using keywords that don't have to be aware of anything (with the exception of the HTML empty elements like br that turn into <br> or <br /> instead of <br></br>).
2:03:45
aeth
And then I'd have to make a linked list where the head is one of those enums and the tail is either a string or another enum representing attributes (again, with me having to enumerate all of them instead of just using keywords). And visually, the end result would look pretty weird.
2:04:57
aeth
And I wouldn't be able to trivially turn that into a syntactic macro. I can do that in CL since my function takes in a quoted s-expression as its main input.
2:23:36
verisimilitude
An issue with Lisp is that it can be odd moving to a new language. I've been learning Ada for a while now and it's not always easy to plan a program out in the detail required, down to the types, and I'm inclined to believe being so accustomed to Common Lisp is part of the reason.
2:27:05
aeth
verisimilitude: give nearly everything its own type and if you change what its type is later on, you just change one line instead of many
2:29:22
aeth
Also, pick a domain that fits the language, if you're just learning it on your own. CL is much better than most languages at the sort of text generation that I was talking about earlier with my HTML example. But if you're doing something that is mostly double floats or something, then that solves most of the type issues in a static language.
2:29:23
verisimilitude
In particular, I've strangled myself with the flexibility of Common Lisp for one program; it works in Common Lisp and I wanted to rewrite it in Ada, yet I find the idea lacks the structure necessary, so I'm going to need to rewrite the Common Lisp before I can get a good idea of how to write it in Ada.
2:30:04
aeth
Oh, and generally, try to avoid linked lists and trees and graphs etc. in such languages. So much harder. Not sure about the details of Ada, though
2:30:41
verisimilitude
Ada 2012 has standard doubly-linked lists, trees, sets, and other such things in its container library.
2:31:20
verisimilitude
Where one may use a hash-table in CL, one can usually use a simple array in Ada, though.
2:31:36
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=d20b6b3c will be valid until 02:45 UTC.
2:32:42
aeth
verisimilitude: Yes, but it's not GCed (by default) afaik, which makes such allocation-heavy stuff way harder imo.
2:33:07
aeth
(Well, allocation-heavy in that sense, vs. an adjustable vector that just keeps allocating to the end but keeps it as one thing)
2:33:19
verisimilitude
It can use GC, but it doesn't. There's not much dynamic allocation, actually, as most things can be allocated on the stack.
2:34:37
verisimilitude
Another nicety of Ada are the pragmas which permit specifying certain things never occur along with banning implementation-specific functionality, etc.
2:48:40
aeth
verisimilitude: Have you ever tried (declare (dynamic-extent foo)) in CL? You can get surprisingly far in SBCL.
2:50:38
verisimilitude
I've written some macros that generate such declarations, but I don't tend to use it manually.
2:51:21
verisimilitude
I should probably go through some of my programs and start adding declarations where they can't cause issues.
2:59:35
sukaeto
aeth: the thing about HTML templating engines is that they're not designed for programmers, they're designed for UX/design people
3:02:45
aeth
sukaeto: The thing about representing something like HTML in s-expressions is that once you get that initial representation that goes from a direct mapping to a string (with all of the relevant escaping) you can do whatever you want with it as prior steps in a process. For instance, I'm not going to write my HTML documents directly in the style of the Gitlab snippit I linked to earlier.
3:03:00
aeth
I'm going to parse Markdown into s-expressions, and then transform them into those HTML s-expressions.
3:03:50
aeth
sukaeto: You're allowed a level of polish in tooling that most people (even most people in the CL community) never get to. CL is really a language for writing declarative languages (which is also probably why SQL-in-s-expressions doesn't really seem like it needs many more layers)
5:13:20
pjb
In lesser languages such as C or Ada, managing types is easy: just use pointers to structures for everything.
5:36:32
aeth
Well, C and C++ and similar languages add an extra level of complexity in API choice that you don't see in CL. Basically, pass by reference vs value. i.e. (at least C-style pass by value) your choice is a pointer vs. copying-everything.
5:42:10
pjb
generally, it's optional. Pascal has it, with var parameters. Modula-2 with INOUT parameters, etc.
5:42:15
aeth
beach: No, what I meant is that for every function you make, you have this mental overhead of whether or not to do foo or &foo and there's probably even a line in object size where it's more efficient to do one or the other, and it's a lot of thinking
5:47:54
aeth
It gets pretty bad in C++ more than C because you want to do OOP like everyone else, so you're doing a lot of Foo *foo that you call with &foo (except when you don't) and that means that in a lot of places you're having to do (*foo)[whatever] or (*foo)(whatever) or whatever << (*foo) and it quickly turns into a mess
5:49:06
aeth
At least compilers are pretty good at telling you (in the first of 200 lines, which you then have to scroll up to read) when you should have used foo instead of &foo to call the function that wants Foo *foo.
5:54:20
aeth
(I'm not sure about Ada and if it addresses this. I wouldn't be surprised if Pascal is similar.)
6:00:51
beach
In metamodular.com/modular-c.pdf I recommend programming with pointers only and using something like the Boehm-Weiser automatic memory manager. Uniform reference semantics is the only sane way of programming.
6:02:43
aeth
I wonder if there's a way to get something like CL semantics... basically, pointers except when it fits in a machine word? I guess not that simple.
6:04:26
pjb
aeth: it wouldn't be safe C. It's better to write pure C code, (C code that is defined by the standard).
6:05:44
aeth
pjb: Wouldn't it be even better to compile a C ABI-compatible binary, but with much Lispier semantics where possible? Technically, only the interop would matter.
6:15:02
aeth
pjb: I don't think that counts because of the runtime. So I guess this is necessarily off-topic except for the obvious choice of the compiler language
6:15:51
aeth
pjb: If such a language existed, you could potentially rewrite ECL in it, though. Then ECL wouldn't need a C compiler, too, since it could just do ECL->this-hypothetical-language->ECL
6:16:34
pjb
aeth: the point is that when you adopt a stereotyped programming style, you necessarily use a run-time.
7:40:22
verisimilitude
With Ada, it's not defined whether copying or referencing occurs with in out parameters, sans some special cases such as limited objects.
7:42:14
beach
The fact that SBCL no longer complains when there is a DEFMETHOD but no associated DEFGENERIC does not suit me at all. My worsening dyslexia results in numerous spelling errors that are not caught.
8:00:19
saturn2
beach: (shadow 'defmethod) (defmacro defmethod (name &rest rest) `(if (typep (symbol-function ',name) 'generic-function) (cl:defmethod ,name ,@rest) (error "~A is not a generic function" ',name)))
8:15:11
Shinmera
ACTION wonders if a general utility to check all symbols for a close Levenshtein distance would be useful
8:20:51
pjb
Here I have a tool to check for "duplicate" symbols, ie. symbols with the same name interned in different packages. https://github.com/informatimago/lisp/blob/master/tools/symbol.lisp#L133