freenode/#lisp - IRC Chatlog
Search
3:06:22
didi
You know... I miss having a COND clause that I could use the result of `test-form', e.g. (cond ((test-form) => (use test-form-result)))
3:19:34
stylewarning
At which people were amazed that a few carefully chosen optimizations made code 50x faster without sacrificing code quality.
3:20:34
stylewarning
Mostly techniques in Common Lisp for identifying areas ripe for optimization, and how to do that
3:28:32
stylewarning
The answer is "probably yes". Working out some details now since I came back from vacation
3:34:30
stylewarning
Yes of course. I'd argue things are a little more nuanced than what he presented (in my opinion, IIRC)
3:38:58
stylewarning
For instance, consider extending his pixel problem to be an array of structs of RGB values
3:40:39
stylewarning
Idiomatic Lisp would be a simple array of structs. You could write special accessors into a specialized array of floats that emulates a flat array of structs. You could even construct a struct when you pull the array out.
3:41:16
stylewarning
You could even remember a pointer to the array the struct came out of so you could setf the struct to transparently setf the array
3:42:34
stylewarning
I would guess that even with all of that involvement, none of it will likely beat some SIMD craziness if a flat array of structs in C.
3:43:26
stylewarning
(One of my long term goals is to think about CL extensions to give you some of that additional power.)
3:45:33
stylewarning
(Franz did some stuff like this and has a YouTube presentation about it. https://youtu.be/S7nEZ3TuFpA Not quite what I want. I want primitives for pinning objects and getting pointers basically.)
3:59:51
mfiano
I would not say that aeth. We've told you time and again, most of a game is not even on the CPU. SIMD is nice, but unless you are doing some crazy physics simulations, a typical game will be using a very small percentage of your processing power.
4:04:42
aeth
mfiano: And I've said repeatedly that that common wisdom only applies to graphics-heavy, AAA games that no one here is making and that simulation-heavy CPU games (not even necessarily physics simulations) can still definitely live on the CPU.
4:05:51
mfiano
Which puts you in the domain of your statement, not the lispgames community. You are the only one I know of that spends years optimizing low level game math rather than making anything remotely like a game.
4:06:12
aeth
RTSes and building games (especially the subgenre of building games with stockpiles) can still fill the CPU.
4:08:13
aeth
Bike: the problem with building games is you can have hundreds or thousands of units doing things at once, on the CPU
4:10:48
Bike
stylewarning: anyway, i'm probably going to try to add arrays of structs to clasp at some point. we need it for chemistry stuff.
4:11:57
stylewarning
The semantics of that reference, it's out-of-line modification, storage, identification on the heap
4:13:37
aeth
stylewarning: What I've been doing is retrieving and setting multiple values in 2D arrays, and covering up that messiness with macros.
4:16:23
stylewarning
Aeth, the most reasonable way I've found to hack it is to just internally allocate as a struct of arrays
4:23:39
stylewarning
Just a macro DEFSTRUCT-ARRAY that's like DEFSTRUCT but the accessor takes an integer N
4:26:05
Bike
yeah, maybe something i should prioritize... dealing with gc might be annoying, but so it goes
4:34:46
vtomole
So anytime a variable is created, that symbol is stored in the environment along with it's value? Are function names also "variables"?
4:47:58
Bike
if you do (second (read-from-string "(defparameter a 2)")), you'll get A, even though the defparameter is not actually executed
4:53:36
vtomole
So read creates the symbols. If I do (Defun square (x) (* x x)). Is square a variable or a symbol? What is the difference?
4:57:20
vtomole
But "square" and "a" are both symbols, it's just that one points to a variable and another points to a lambda expression. Is that the correct type of thinking?
5:00:22
beach
vtomole: Check the glossary entry for "lambda expression" in the Common Lisp HyperSpec.
5:01:26
White_Flame
it's the pairing of a symbol and a function object, in the case of a named function
5:02:41
beach
function n. 1. an object representing code, which can be called with zero or more arguments, and which produces zero or more values. 2. an object of type function.
5:05:22
White_Flame
and it's technically not "the function SQUARE", but "the function named by SQUARE"
5:33:56
jmercouris
hello everyone, let's say given the string "hcpr", and the other string "helicopter" what kind of mechanism could I use in lisp to identify that the sequence of characters "hcpr" appear in order in the string "helicopter"?
5:34:25
jmercouris
i was thinking about using regex something like h*c*p*r where * represents one or more arbitrary chars
5:37:18
jmercouris
ppcre seems really good for regex, but this cl-string-match also has some cool features i could just drop in for more sophisticated matching
6:11:08
jmercouris
so basically what i wanted to do was iterate char by char and make a string appending the regex to do matching
6:12:20
beach
When the reader sees #\ it creates such an object, and when the printer sees such an object, it prints #\.
6:13:19
jmercouris
I'm thinking of what the best way to build up the string is without doing a ton of concactenation
6:14:01
beach
You can build a string either by using an adjustable string and adding characters to the end, or you can use a string stream.
6:14:30
beach
If you use make-array with a fill pointer and with element-type 'character, you get such a string.
6:47:36
jmercouris
so I have written the following code to try to do re matching: https://pastebin.com/0xFRmcRP
6:47:48
jmercouris
unfortunately, I am getting "#<string-output stream 00000001091361e0> is not of type SEQUENCE."
6:50:27
jmercouris
i've already read it a few times, i can't seem to understand the documentation style yet
6:51:02
beach
with-output-to-string returns the resulting string. That's what you need to use for the match.
6:54:01
beach
With DOLIST, you first have to convert the string to a list of characters, which involves consiing.
6:55:32
beach
It may not matter in your case, of course. But it is also more idiomatic to do it that way.
6:56:31
jmercouris
i come from a python background where there are very clear "pythonic" guidelines, and since there is nothing like pep8 for lisp, it has left me a bit lacking
6:58:00
pjb
It's not as formally documented as in the PEP. In lisp, a lot is encoded into the editors and IDEs.
6:58:21
jmercouris
that's what I was saying, like that's just one guys opinion, i mean a very respected guy, but it's not like an "official" organization
6:58:57
pjb
jmercouris: there's no official organization, until you create a startup named "Official", and then you will only be able to impose your rules to your employees.
6:59:22
jmercouris
well, even if it was something like ansi publishing a list of guidelines, i'd consider that more official
6:59:57
pjb
jmercouris: the assumption with lisp is that lisp programmers are intelligent. They're able to not shoot themselves in their foot, and they're free to use their own rules.
7:01:03
jmercouris
all valid points, I'm just saying it would be nice if there was a "standard set of guidelines" or however the semantically correct way of saying that is, to guide lisp programmers to create code that is consistent
7:01:10
beach
jmercouris: A standard for a programming language is an official document that determines exactly what an implementation must or is allowed to do in order to call it an implementation of that language.
7:01:34
jmercouris
in this sense, there exists a standard for lisp, but i'm looking for something like pep8, whatever you'd call that
7:02:16
beach
jmercouris: No guideline would tell you not to convert a vector to a list before iterating of the elements. That's just standard programmer knowledge.
7:03:08
pjb
jmercouris: there's the CDR as document repostory. https://common-lisp.net/project/cdr/ You can write PEP-like documents and publish them there.
7:03:53
beach
jmercouris: The LUV slides that I gave you a URL to is as close to an ANSI guide you can get, given that Kent Pitman is one of the main authors of the standard.
7:06:00
beach
jmercouris: Well, you are out of luck, because Common Lisp is a language with an independent published standard, and there is no official organization deciding what you should or should not do with it. The advantage of that is, of course, that there is no organization that can arbitrarily decide to change what it means for a program to be valid Common Lisp by arbitrarily changing the language definition.
7:07:39
beach
jmercouris: And, as I often say in my talks to industry people, a project leader to decides to use a programming language without an independent standard, i.e. a language that can evolve arbitrarily at the whim of some official organization, should be fired.
7:07:49
jmercouris
beach: I'm not trying to start a war :D I'm just saying a little more guidance would be nice, most likely my opinion will change as I become more experienced with common lisp, I've only been seriously working with it for about a month
7:08:47
jmercouris
beach: I can definitely see the advantages of a completely free language, it's like an "open source" language in a way
7:08:59
beach
jmercouris: You are getting hints here. But the one about converting a vector to a list before iterating over the elements is not a guideline item. It is common sense, and will be obvious to you when you know more about how the language works.
7:09:05
jmercouris
not in a literal open-source sense, but in the fact that it gives you some power as the user
7:09:58
beach
jmercouris: I don't even know what an "open-source language" could possibly mean. One where each person is free to change its definition at any point in time?
7:11:32
beach
Not to talk about the proliferation of IRC channels #lisp-according-to-bob, #lisp-according-to-bill. There would be a single person in each channel.
7:12:12
beach
jmercouris: We are very lucky here in #lisp in that there is a well-defined basis for what we are discussing.
7:15:11
jack_rabbit
Common lisp, in some ways, was constructed in order to solve the problems caused by exactly what you describe: many different and incompatible lisps.
7:15:15
beach
jmercouris: The current trend is to confuse "programming language" and "programming system". If you add to that a single organization (or worse, a single person) with the power of changing the language/system at a whim, you get what ought to be a no-no for any serious programming project.
7:16:44
jmercouris
beach: I'm saying that if the language definition is not controlled by anybody, you are free therefore to adopt it or not adopt it, and you won't have to bend to the will of some random corporation
7:16:52
beach
jmercouris: So, unless you are just doing hobby programming that you don't mind throwing away at regular intervals as a result of the decisions of some "official organization", I strongly suggest you stay away from such languages/systems, and go for a language with an independent standard, and multiple suppliers of implementations.
7:17:11
jmercouris
it's true that there are many possible derivatives that will emerge, but at least a couple of them are bound to be popular enough to have a community to support them
7:17:58
beach
jmercouris: You are contradicting yourself. On the one hand, you want everyone to be able to change the language definition. On the other hand, you want the "official guidelines".
7:18:21
jmercouris
beach: I would agree with that for extremely long term projects, or mission critical things, I think it is okay sometimes to use controlled languages when you are locked in. Let's say you are on windows, it would be very advantageous to use C# despite all of the problems you described
7:19:01
jmercouris
beach: i'm not contradicting myself, in the python organization, it is an official org, but anyone can join and change the definition through the submission of pep guidelines
7:19:02
beach
jmercouris: Plus, it is not forbidden to change the Common Lisp language, even though it has an independent standard. You just can't claim that the result is a conforming implementation. I see no restrictions here.
7:20:20
phoe
Lisp is a very different language compared to Python because a) you don't need to submit any pep guidelines to *drastically* change how the language works, b) there is a standard from 1994 that describes what an unmodified language should look like - and that has given Lisp an insane lot of stability since then.
7:21:33
jack_rabbit
It is amazing to find libraries from decades ago that still load fine today. I don't see that in any other language I've used. Even ones with solid standards.
7:21:39
beach
jmercouris: The existence of an independent standard is not a constraint. It is the other way around. I mean, if you don't like it, just pretend it doesn't exist and do whatever the Python people do. But if you want to have a precise definition of the language that you can be sure will not be altered, then accept the independent standard.
7:22:30
phoe
on the other hand that standard from 1994 gives you enough power to completely change how the language reads, expands, compiles, runs
7:24:16
beach
jmercouris: One that is published by an organization that is not the supplier of an implementation, or at least not of the only permitted implementation. It is also required that this standard be given a unique document number, so that it can be referred to uniquely.
7:24:52
Shinmera
phoe: Considering CLtL1 was published in 1984 and a good bunch of programs were written against that and still work, it's actually even longer.
7:24:55
jmercouris
I don't see what the issue therefore is with this SOMEBODY being an organization that publishes guidelines
7:25:43
Shinmera
jmercouris: Because a standard without implementations following them is pointless. See CDR.
7:26:35
phoe
3) some people have thrown ideas of how Lisp *could* look like, but these have not been widely adopted
7:28:07
beach
jmercouris: The ANSI standard is an excellent basis. Any additional functionality can be (and is) handled by additional libraries.
7:28:34
beach
jmercouris: Because Common Lisp has Common Lisp macros, libraries can also supply new syntax, which is impossible in most other languages.
7:29:43
phoe
but what beach said, you don't need to change the standard to modify the language - you don't publish new standards, you publish new libs, which is a drastic difference compared elsewhere. Lisp isn't changed, Lisp is grown.
7:29:45
jmercouris
I mean, I get that, I just don't see what the issue would be there was a comittee responsible for evolving the language over time
7:30:24
Shinmera
They paid a lot of money to get the standard made, in hopes that it'll save them from future monetary losses.
7:30:54
phoe
I guess, Lisp is still alive and kicking, both in the commercial and non-commercial world
7:31:56
beach
jmercouris: Many people here are very happy that there is not an arbitrary committee, company, or organization deciding to make their programs non-conforming at a whim.
7:33:11
jmercouris
basically the secret sauce is the defmacro, because no need to invent new forms or syntax that are adopted by an implementation, you can just make a lib that supports it
7:33:26
jmercouris
this also allows you to change how you use the language, and allow you to use code from as far back into the past as you like
7:34:04
Shinmera
There are some things that genuinely need implementation changes to do in a way that's not horrendous, and you'll find people lamenting those things in here if you stick around long enough.
7:34:36
jmercouris
phoe: interesting, i'll have to read about those, for now, i'm just struggling to learn the basics
7:34:49
phoe
so you can do crazy stuff like (with-c-syntax:with-c-syntax () #{ format (t, "Hello World!"); }#)
7:34:56
phoe
or (with-c-syntax:with-c-syntax () #{ int i, sum = 0; for (i = 0; i <= 100; ++ i ) sum += i; return sum; }#)
7:41:26
beach
jmercouris: "beach" is just a literal translation into English of "Strand" (the `h' is added for kicks).
7:44:57
phoe
this is McCLIM that's been used to recreate environment like the ones of ye olde Lisp Machines
7:45:18
jmercouris
beach: yeah, i saw that link on reddit, you'll see i also commented with my project i'm working on
7:49:12
phoe
jmercouris: it's a part of programmer enlightenment. if your ego prevents you from acknowledging how much you don't know, then it'll be a very successful ego indeed
7:49:46
jmercouris
phoe: nah, I'm 100% joking, I've been programming ~10 years now, the computer has taught me how dumb I am :P
7:57:31
beach
jmercouris: In case you are interested in McCLIM, some of us hang out in the #clim channel.
8:03:54
Shinmera
hjudt: I've made some changes to the tutorial to address the concerns you had. Thanks again for the feedback!
8:47:43
beach
Normally, I would avoid it, because error messages can then be confusing, but now that I will have source tracking, I imagine the error messages will be in terms of locations in the source code, so that it will be obvious what code created the problem.
8:50:18
beach
Similarly, I can turn LET* into nested LETs, as long as I am careful to parse the declarations ans move them around as appropriate.
8:51:31
beach
By doing it that way, the logic for handling new environments, for binding the parameters (lexical or special) will exist in one single place.
8:53:30
beach
[without a dangling participle:] By doing it that way, I can have the logic for handling new environments, for binding the parameters (lexical or special) in one single place.
9:05:26
beach
Besides, the same problem of emitting good error messages exists already because of macros.
9:24:24
oleo
macro forms cannot expand into declarations. declare expressins must appear as actual subexpressions of the form to which they refer
9:26:56
oleo
if the first macro expression doesn't contain a declare form itself it will be expanded as usual....and when it refers to a second expression (which is another macro somewhere else) that one will be expanded too
9:30:15
oleo
since the code walker isn't required to expand macros before checking for declarations.....
9:31:39
oleo
and when it already checked for declarations before the macro expansion, it is too late for the declarations to get effect
9:33:21
oleo
what does the macro expansion turn into when it checked for declarations already before the expansion ?
9:40:40
oleo
if the code-walker can't walk a macro to check for if it contains declarations, and hence can't distinguish if the expression is a declare-form of a sub-expression or if the declare-form is a result of the expansion of the macro.....
9:41:41
phoe
this implies that forms as simple as IN-PACKAGE, DEFUN, DEFMACRO, DEFVAR cannot be walked
9:45:12
oleo
all i see is the actual declare-form wrapped by a function/special-form in the expansion
12:35:25
didi
I think I finally understood why PCL uses `with-standard-io-syntax' after trying to save a list to a file with `*print-length*' set to 42.
12:58:46
Bike
what is the point of this paste. you just posted this with no context or explanation. do you expect a response
13:13:22
phoe
you just posted a way of telling SBCL that it should shut the fuck up and evaluate whatever you gave it without printing any notes, warnings or errors
13:17:49
jack_rip_vim
hello, I have a question about those lisp that has been shared at ckili, are those modules need to install c library so that I can use it?
13:22:44
jack_rip_vim
hmm, maybe I should figure out those libraries that require c part. I am trying to make a lisp os. so I need to know if those libraries require c part things
13:25:38
jack_rip_vim
I may need to change some of the code on clisp, so that it can be a nice common lisp shell
13:26:52
jack_rip_vim
I know, in 1980s, there are lisp machine, so maybe we can make it popular again
13:27:02
godratio
ooking forward to being part of the community here as lisp will be my second language
13:27:39
didi
jack_rip_vim: I don't doubt your capacity, but implementing "a lisp os" sounds like a daunting task. I would trying finding something smaller to work on.
13:31:32
godratio
I like the idea but dont do it for the language do it for what the advantage of having it done in lisp would be not for the language. THe original concepts of lisp and make it something not about languages but about what is capable with a very flexible system
13:33:28
godratio
no one cares what language the os is in onlyt it capability to the users and the developers.
13:56:51
didi
My debugging so far has been printing forms, evaling functions with C-u C-c C-c and occasionally evaling forms inside the debugger.
13:58:10
Shinmera
Don't forget pressing 'v' on a stack frame to jump to the definition and potentially see the form in the definition that the error is in.
13:58:56
Shinmera
Just using TRACE is also useful a lot of the time to avoid having to write manual print stuff. Otherwise you can also insert (break) at points of interest to explicitly invoke the debugger and see local variables and whatnot.
14:00:04
Shinmera
Occasionally I also use STEP when I already have a rough idea of the error location.