freenode/#lisp - IRC Chatlog
Search
3:41:19
jasom
that's the question a docstring should answer, with a secondary question of "when should I use this function"
3:41:33
jasom
if someone is looking at the docstring, they think they ought to use the function, but aren't sure how
3:42:03
jmercouris
e.g. second arg should be an int, this integer moderates the function in this way
3:42:56
aeth
e.g. if there's a meaningful return value "Returns foo..." or "and returns foo..." probably should be in that docstring
3:44:16
aeth
I usually write that in prose, but you could probably get away with literally just listing those
3:44:26
jasom
jmercouris: they should *not* document how the function works, that belongs in comments.
3:45:39
aeth
Ideally, the way the actual function works should be obvious, even if you need to add helper functions (there's basically no penalty if you move stuff out into meaningfully named functions that are inline)
3:46:13
jmercouris
aeth: I thought declaring functions inline within a function form was a bad idea?
3:46:54
aeth
jmercouris: no, I mean move stuff to top-level helper functions that are obvious if some part of your function isn't obvious, rather than comment
3:47:20
jasom
jmercouris: inputs/outputs/side-effects is a good checklist for "how do I use this function"
3:47:43
jmercouris
if there is enough complexity that warrants a comment, you should probably abstract it out into a function?
3:47:43
aeth
I'm agreeing with jasom that "that belongs in comments", but then adding that imo if you do need to comment, you probably should break the function up
3:49:11
jasom
jmercouris: aeth is suggesting (foo bar baz (biff (boff buff))) ;; I can't just frobnotz bar and baz because sbcl's optimizer is dumbs --- instead: (frobnotz-efficiently-on-sbcl bar baz)
3:50:18
aeth
jmercouris: If you are mostly going to avoid side-effects, you might like the Scheme convention of ! when there are side effects present
3:51:04
Zhivago
jasom: Perhaps that's something that would be better solved by adding a compiler-macro for sbcl rather than changing the code.
3:52:19
aeth
Pretty much the only thing in "Conventions in Scheme" that you should never do and I've never seen is $foo for constant (since CL has +foo+) http://www.cliki.net/Naming+conventions
3:53:26
aeth
jmercouris: The problem with alternatives to "foo!" is that there is no direct CL equivalent. The n in nfoo means "non-consing" but that doesn't guarantee that it is destructive... also you can be both destructive and cons
3:59:37
aeth
I think you don't see foo! in CL because Lispers don't care about destructive code as much as Schemers... but if you're writing part of a program that does care, why not use that convention?
4:02:34
aeth
jmercouris: Oh, and before you mentioned about documenting types. Don't trust the user imo.
4:03:48
aeth
There are two approaches. check-type is 100% portable, but not necessarily what you want. Type declarations might just assume the type in Cthulhu Lisp or some other non-euclidean eldrich abomination lisp from before time, but should work as expected on most modern Lisps when saftey != 0 (and that should always be the case)
4:05:09
aeth
A ton of code written recently uses type declarations and assumes they work as expected, with type checking when safety != 0
4:06:37
aeth
Iirc, an added advantage of type declarations is that they don't need to check type if they're running on Lisp machine hardware that is designed with Lisp types in mind.
4:13:03
aeth
It can generate very efficient code for non-bignum numbers and sequences because a lot of built-in functions are generic over numbers or sequences (like + or map)
4:13:31
aeth
Although a check-type should produce a very similar result, just with the type-checking in the function instead of before the function
4:14:42
jasom
jmercouris: there is no exaustive list of types since e.g. (integer 5 8) would be all integers in the range [5,8)
4:14:58
aeth
Actually, the checking in a foo with type declarations seems to be considerably more concise than the checking in a foobar with check-type when I use sb-disassem:disassemble-code-component to see the full disassembly (which disassemble does not provide)
4:15:12
jasom
jmercouris: but the hyperspec lists types in the various sections (e.g. the numeric types are listed in the chapter on numbers)
4:15:36
aeth
this might be SBCL specific, but I think it's because of the semantics of check-type vs type declarations
4:16:30
aeth
Hmm, this seems to be the difference in SBCL. check-type will let you insert a valid replacement and a type declaration won't
4:18:37
jmercouris
ah, so a type is a function that accepts args to produce some sort of check function?
4:19:15
jmercouris
well (integer 5 8) looks like a function call to "integer" with the arguments 5 and 8
4:20:23
jasom
you will almost never define a new parameterized type in lisp because Lisps type parameterization is not very powerful
4:20:54
aeth
You almost certainly want to restrict the integer type for it to be useful. "fixnum" is the laziest way to do it, but is non-portable. Stuff like (unsigned-byte 8) and (unsigned-byte 32) are great because they're almost certainly going to be supported in 64-bit implementations' specialized-arrays
4:21:38
aeth
But if you want type information to produce more efficient code you really want the compiler to know that the integer is never going to be a bignum (which might have to require more complicated code on your end)
4:22:27
jasom
jmercouris: cmucl and sbcl at least will emit some compile-time checks in the presence of types, and will always emit run-time errors if safety is non-zero
4:22:27
aeth
Afaik, for the most part, the compiler already knows what the type has to for a variable be by the function you try to use on it.
4:22:33
Bike
if you want an actual assertion, use check-type or negotiate with your vendor (i.e. read the manual)
4:23:19
jasom
jmercouris: yeah, once you use a lisp like that, it becomes so obviously the right way, that most implementations have copied it
4:23:47
aeth
Bike: I think it's more nuanced than that, i.e.: For the most part the compiler does know anything between function boundaries because (foo 42) might return 43 now, but could be redefined at runtime to return "Hello, World!"
4:24:22
jmercouris
I just want to emit useful error messages to the user if they have supplied an incorrect type
4:24:51
jmercouris
because if the compiler knew what I was trying to program, it could possibly do it for me instead of me having to type it out :D
4:27:17
aeth
jmercouris: instead of having a foo-fixnum, foo-single-float, foo-double-float, foo-bignum, etc., you can just have one foo
4:28:09
aeth
If it's inline, it produces exactly the same code as if you had that many inline functions
4:28:34
aeth
But... you could do an inline function call as a sort of compromise (and that's probably common enough that that library should support it imo)
4:29:41
aeth
(class-of (make-array 3 :element-type 'single-float)) => #<BUILT-IN-CLASS SB-KERNEL::SIMPLE-ARRAY-SINGLE-FLOAT>
4:29:48
aeth
(type-of (make-array 3 :element-type 'single-float)) => (SIMPLE-ARRAY SINGLE-FLOAT (3))
4:30:05
aeth
Not only is that class not portable afaik, it also doesn't have some critical information, like length
4:30:54
aeth
And, yeah, specialization store is most useful when you want to inline or at least inline the function call so the runtime dispatch is avoided
4:31:47
aeth
Dealing with C libraries through CFFI is a nightmare... and C++ is ultra-nightmare or something.
4:45:26
aeth
jmercouris: My personal design philosophy for my Lisp code is that anything that can be done ahead of runtime should.
4:59:50
jmercouris
beach: Good morning, and in case I don't see ya, good afternoon, good evening, and good night!
5:02:36
aeth
Do implementations turn (list 1 2 3 4 5) into (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 nil))))) or is there a better way that I'm overlooking?
5:03:14
jmercouris
aeth: I don't see how you could avoid the linking operations when making a linked list
5:04:58
aeth
https://github.com/sbcl/sbcl/blob/0d398686138fa05504c57567d28130cb85fb143e/src/code/list.lisp#L343-L345
5:09:37
aeth
To save people a click, the source is just this when newlines and the docstring are removed: (defun list (&rest args) args)
5:10:28
pillton
aeth: Specialization store can do the optimization you were talking about before. https://github.com/markcox80/specialization-store/blob/master/tests/standard-store-syntax-layer.lisp#L357
5:11:11
jmercouris
just because SBCL happens to make a list of args and then returns that list, doesn't mean that along the line it didn't make the list in the way you are describing
5:11:38
jmercouris
I don't see how it is avoidable to make a linked list without linking the elements of the list
5:12:25
aeth
pillton: so named specializations are inline function calls instead of runtime dispatch?
5:15:59
aeth
jmercouris: And that's why I promote specialization-store, btw. The library literally anticipates my feature requests and then implements them in the past
5:22:04
aeth
jmercouris: Possibly, but mere blockchains aren't enough. Smart contracts are what people want now.
5:33:25
aeth
jmercouris: Formal verification for general purpose programming, yes, but smart contracts kind of need them because hundreds of millions of dollars are on the line.
5:33:52
aeth
So you kind of have to program more like NASA and less like a JavaScript web developer when you're doing an Ethereum clone
5:34:52
jmercouris
I've done formal verification, and, it is not a fun time, nor is it easy, nor is it even possible truly except for on some embedded systems
5:34:53
aeth
They're absolutely not doing anything close to reliable programming. e.g. https://news.ycombinator.com/item?id=16148608
5:35:32
aeth
jmercouris: yes, but solving it for smart contracts on blockchains is probably a $1,000,000,000 idea.
5:36:27
jmercouris
people literally PAY for microsoft, when there are free pieces of software that are better, blows my mind
5:36:30
aeth
Reliable smart contracts in Common Lisp practically writes itself for Hacker News. Guaranteed #1 position on the site. :-p
5:37:41
jmercouris
like "what makes CL great is the fact that it recently surpassed javascript for number of active developers"
5:40:28
aeth
jmercouris: My favorite part is that the language apparently has no garbage collection *and* no manual memory management.
5:42:37
aeth
And it's just integers, so you'd have to call in a contract that is a fixed-point arithmetic library and hope you can trust it iirc
5:43:51
jmercouris
I could design a better language by throwing darts at a board of language features
5:45:17
aeth
They apparently decided to release early and hype it so that they could then get the resources to implement it properly.
5:45:55
aeth
jmercouris: Oh, and apparently the reason it's slow is not because it's distributed but because it runs in a 256 bit VM.
5:46:38
jmercouris
writing fast distributed software is hard enough with all of the scheduling and memory challenges, why do this?
5:47:26
aeth
I'm guessing that that's probably large enough to express all of its currency as an integer (which is necessary because of how badly it handles numbers), whereas 64-bit and 128-bit wouldn't be
5:49:28
jmercouris
to be fair, when I was 20, I was struggling to write my own implementation of malloc
5:50:20
aeth
jmercouris: If you are serious, I'd start with a fixed-point math library. You generally want decimal fixed-point math for currency (e.g. at 1/10000 to represent 1/100th of a cent), although if it's cryptocurrency, you might just want to work in powers of 2 all of the time for efficiency (i.e. use ash)
5:52:06
aeth
jmercouris: Well, I know the pain point you're going to reach: cryptography. I wouldn't trust any pure-Lisp crypto libraries with real money of any kind (not battle-tested enough), including cryptocurrency.
5:53:03
aeth
If you could actually do an ICO, you could pay some crypto person to write a pure-Lisp crypto library that is reliable, at least in SBCL
5:54:38
aeth
jmercouris: No, if you were serious about writing a white paper for an ICO, just get a PhD to write it and invite a PhD to the team. PhD + writes lots of papers. There are several here afaik.
5:55:15
jmercouris
aeth: I'm totally joking, I bet the SEC is going to begin regulating ICOs in the near-term and I don't want to be involved in that legislative nightmare that will arise
5:55:21
aeth
I'm sure writing a VM in CL to run a blockchain-distributed reliable program (Rust-like or Haskell-like) would be a project someone would want in on
5:56:18
aeth
jmercouris: An ICO is almost certainly a bad idea, but a blockchain probably has enough interest from SEO-approved investors at this point.
5:56:44
jmercouris
aeth: That is probably true, just throw that word into any presentation and people just lose it
6:00:08
aeth
jmercouris: All you need is: a fixed-point math library, a proof-of-stake blockchain, a VM to run smart contracts on that blockchain, a Haskell-like or Rust-like language with Lisp syntax to run on that VM. That would near-guarantee a $1,000,000,000 market cap for that cryptocoin. There are already 38 (!!!) valued that much.
6:01:12
jmercouris
the key here is marketing, there are thousands, if not tens of thousands of cyrpto languages
6:03:56
aeth
There are a lot of shitcoins with nothing to offer except being a github fork of Bitcoin or Litecoin or something. It would be hard to find a unique name for a cryptocurrency
6:07:58
aeth
this name is probably taken a million times for a million different things, but "clash" would be the perfect name, imo. A pun on the "cl" prefix a lot of cl libraries/programs have, and "cash"
6:14:00
jmercouris
so actually, the language is irrelevant to them, it just happens to be in cl, which is conveniently easy for us
6:14:26
aeth
there are some investors on the Lisp hype train, although probably not as many as in the past
6:16:07
jmercouris
we could just call it the "Smart" platform "self-learning machine application technology"
6:16:37
aeth
"closure" would be the most clever name of your list, too bad it is too close to clojure and clozure
6:19:21
jmercouris
sounds like a plan, I'm going to sleep for now, but let me know which yachts you'd like to check out tomorrow
6:22:09
aeth
(It's funny how a game franchise about stealing virtual vehicles somehow became a game about buying virtual vehicles with RL money.)
6:25:27
aeth
It would actually be interesting for the #lisp community to explore the idea of Lisp smart contracts, even though it's about 4 years too late to make real money from the idea.
6:26:51
aeth
Imo if you're semi-serious about seeing where this could go (1) don't expect any money because of all of the competition, (2) whoever writes white papers for fun gets to be project lead
6:30:08
aeth
I do think that the Lisp community could make something better than Ethereum fairly easily with the existing ecosystem
9:40:55
shka
Shinmera: hey, you there? How should i setup r-data-model and r-simple-auth so they both would use PG?
9:41:28
Shinmera
shka: They both use the database interface, so whatever database implementation you load will be used.
9:42:09
Shinmera
Actually r-simple-auth doesn't use the database interface, just the user one. But the default for that uses the database, so.
11:44:44
pagnol
I usually add a line like `find -name '*.lisp' | entr run-the-tests` to my makefiles
11:59:02
shka
i want to use auth module to have signing up, logging in, nothing out of ordinary i think
12:00:36
Colleen
shka: Function user:check https://shirakumo.github.io/radiance#FUNCTION%20USER%3ACHECK
12:02:01
shka
so i depend on auth now, those this mean that somehow this should already work in basic form?
12:05:04
Shinmera
For localhost, which does not have subdomains, you can reach it through a routing like so: http://localhost:8080/!/auth/login, which is translated to http://auth.localhost:8080/login internally.
12:05:40
Shinmera
On your deployed system you would either set up a proper auth subdomain, or set up a route to translate it.
12:06:19
Shinmera
The gist is, each module gets its own subdomain so that it can use the full path space for itself.
12:07:35
Shinmera
You can set it up so that the login page is reachable through /auth/login, or /userlogin, or whatever you want, but that's a step for later.
12:16:55
Shinmera
So if you define a page on the uri "foo/bar" that'd be (uri-to-url "foo/bar" :representation :external)
12:19:31
Shinmera
Right, if you do it from the REPL that's what you'll get. Radiance has a list of top-level domains it knows about. By default that's "radiance" and "localhost". When you're running a translation from the REPL it doesn't really know which one you mean, so it just picks the first one.
12:19:43
Shinmera
When you do a translation within the context of a request, it knows which domain to pick based on the request.
12:20:15
Shinmera
It also might know additional information, such as that you used some other translation route like the /!/ prefix, and uses that to translate back.
12:26:28
shrdlu68
varjag: I fixed yesterday's issue: https://github.com/shrdlu68/cl-tls/commit/2155de591134834184dcc1d19321da65a52eb254
12:29:08
shrdlu68
varjag: The OCSP issue still persists, because I've not yet implemented OCSP stapling for cl-tls. Most implementations fall back to "old-style" OCSP only when the server does not support OCSP stapling. I'll do that soon as I get some time.
12:51:18
makomo
beach: i re-read your essay yesterday for fun and found a little typo -- ctrl+f ",," :-)
13:07:40
phoe
this sounds strangely correct - by the time you're using double unquote, you're most likely already wrong somewhere
13:08:33
makomo
i was thinking how i should have said "you probably meant to only single-unquote this space" :-)
13:54:06
makomo
oh, regarding backquote, i have a question. i've been studying/inspecting the once-only macro (again) recently, and it uses ,,@
13:55:20
makomo
at first i was confused because what is the leftmost unquote supposed to do? i confirmed experimentally that it unquotes every single element of the spliced-in list, but i can't exactly see where this behavior is specified in http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm
13:58:10
makomo
i should also probably link the source of ONCE-ONLY, here's one: https://stackoverflow.com/questions/9808928/understanding-how-to-implement-once-only-lisp-macro
13:59:55
pfdietz
I've always found it easier to unpack macro code using nested backquotes into a series of functions.
14:01:35
makomo
and also, i feel like the page doesn't do a good job of explaining nested backquotes/unquotes. there's only a single line at the end and it's not clear to me what "should be *expanded* first" and "occur in a *row*" mean
14:02:32
makomo
(1) "expanded" because what does "expansion" even mean in this context and (2) commas can appear in a "row" but with ' and @ interspersed inbetween
14:26:13
beach
makomo: Unfortunately, the only way to understand backquote that I know of is to apply the algorithm they show. The Common Lisp HyperSpec is meant for people who implement Common Lisp, so it is kind of understandable that it is not very pedagogical in this respect.
14:27:40
makomo
beach: yeah, i agree with that, but i'm having trouble following their definition since the backquote is nested. i have no problem following the formalities for a single level of quotation
14:28:46
makomo
am i supposed to treat ``(...) as `<basic>, where <basic> is then the rest, i.e. `(...)?
14:29:30
makomo
but then again this is also confusing because of that "expanded" thing at the bottom :^(
14:31:47
makomo
so in the case of ``(...), that would be equal to `<form> where <form> is the result of processing `(...)?
14:34:53
Xach
I share this not to mock, but because it is to me a novel (if novice) use of some functions I rarely use
14:36:48
Shinmera
I'm confused as to when you'd even have a list of characters spelling out undefined.
14:40:05
phoe
https://github.com/ZykeDev/CLispJSONParser/blob/master/json-parsing.lisp#L326 - looks like CL:BUTLAST
14:45:45
Xach
I think it's a pretty good example of "I have a set of tools and I'm going to use them to get what I want no matter what". The kind of determination that will improve with access to more tools and tricks.
14:46:38
phoe
So they likely don't know CL in-depth, but they nonetheless used enough of it to implement something that works.
14:49:06
Xach
on the other hand, it can really help to have at the back of your mind that curiosity of "is there a better way?" but sometimes constraints prevent listening too much to that.
14:53:00
Xach
https://github.com/borodust/claw had a nice description ("Autowrapping FFI") but the readme says "don't use"
14:53:13
|3b|
ACTION doesn't know prolog, does the prolog version just give up halfway through parsing undefined?
14:53:46
Xach
i was also bummed that https://github.com/mak08/cl-map is "just" ffi. i have part of a lisp shapefile parser in progress.
14:56:38
dmiles
|3b| well the good part of that file is it is prolgo for very simplistic prolog impls
14:57:24
dmiles
(that is it doe4st use DCGs) nornmally to parse json you'd use about code 1/2 that size
14:57:36
Xach
schweers: I know it isn't practical all the time, but I do really like a "pure" lisp solution because it is likely to be easier to set up that managing foreign libraries (and foreign memory, code, etc)
14:58:06
flip214
makomo: don't despair, I've had a major leap in backquote understanding a few months ago (after several years of using Lisp), but I'm still not sure about all the implications
14:59:24
Xach
Sometimes it is too much work to make it fast enough for the task at hand. Or it's too much work to recreate some very useful library.
14:59:35
makomo
flip214: i have this "intuitive" and "experimental" knowledge of backquote, but find that i can't read out some of the things i know about backquote from that formal definition because it's too vague about the nested syntax
14:59:58
Shinmera
On that note, I'd love it if someone translated stb_truetype to Lisp and added SDF
14:59:59
mfiano
As do I. The only place I use cffi is only indirectly, and pretty much required: Interfacing with GPU drivers (OpenGL) and creating a window/context (sdl).
15:01:18
Shinmera
Signed Distance Fields. A technique to get much sharper characters at differing resolutions to the natively rendered atlas.
15:01:20
makomo
flip214: i know what the thing in ONCE-ONLY will produce (just produce though, i'm not claiming to completely understand ONCE-ONLY yet :-)), but i don't see how i would apply the formal definition from the spec to get to the same thing
15:01:25
mfiano
Better yet would be a Lisp implementation of MSDF or PSDF, as SDF is pretty horrible with certain input.
15:02:35
Shinmera
Rendering each character from font descriptions is too expensive, so you cache the characters you need in an atlas that is tightly packed.
15:04:31
Shinmera
Could use that to render the atlas, I suppose, but that still leaves implementing the packing algorithm and SDF.
15:12:50
schweers
Xach: sorry, was afk for a moment. I understand where you’re coming from. I was just trying to say that I never found another FFI which was as pleasant as CFFI (and I guess other FFIs for lisp are similarly pleasant).
15:13:05
shka
Shinmera: do you perhaps have any idea, why my pages won't load if I load file with pages, but it works if i compile individual pages definitions?
15:13:40
schweers
so using an FFI for lisp seems to me to be much less of a hassle than using an FFI for lesser languages.
15:14:54
Shinmera
shka: Beyond what's written down here I don't know. https://github.com/Shirakumo/radiance-tutorial/blob/master/Part%208.md#my-page-is-not-being-called-when-i-open-it-in-the-browser-what-is-going-on
15:15:17
Shinmera
shka: I run Radiance in production, so it'd be odd if I had to manually C-c all the pages :)
15:16:06
shka
Shinmera: it may be the case that I am doing things in peculiar way, I will let you know once i figure this out
15:16:34
Xach
schweers: I have perhaps an irrational fear of foreign code and memory crashing my session entirely.
15:18:17
borodust
mfiano: well, to be fair, that's a fork of my fork ;p since yesterday i can actually remove bodge-autowrap (and would do exactly that today) because i moved all of bodge projects onto :claw
15:19:06
borodust
Xach: while we are at it, what are the policies for accepting wrappers with compiled libraries into quicklisp?
15:20:01
Xach
borodust: no special policy. it should work on multiple lisps and must absolutely work on linux/sbcl