freenode/#lisp - IRC Chatlog
Search
4:08:01
ghostyyy
iqubic, that only solves one half of the accidental caputre problem, the problem where your macro binds a name already in its context
4:08:15
beach
iqubic: Certain ideas in programming language design want to protect the programmer from himself/herself, so the language is trying to make it impossible to introduce certain problems.
4:08:23
ghostyyy
the other half is where the macro's context binds a name which has the same name as a global
4:18:26
drmeister
Hygienic macros are more important in a Lisp-1, with a single shared namespace for function names and variable names. Common Lisp is a Lisp-2 (or more?) and problems that hygienic macros solve in a Lisp-1 are more conveniently solved with GENSYM.
4:19:38
pfdietz
Also, there's less problem with overriding of functions by local variables in CL. Go ahead and use 'list' as a variable name, none of that schemish 'lst' stuff.
4:19:46
ghostyyy
drmeister, what about the problem i mentioned, where some code shadows a global variable, which is also used by a macro, and then that macro is invoked inside of that context?
4:20:45
Bike
yes. cl also prevents shadowing standard names, which mostly makes that not a problem, though it's not a very "clean" solution
4:21:33
beach
ghostyyy: Not sure whether you are talking about the expansion code or the expanded code.
4:22:05
Bike
(let ((x 4)) (macrolet ((m () 'x)) (let ((x 5)) (m)))) => 5 instead of 4, i'm guessing.
4:22:36
pfdietz
You don't want information to be passed down into macros using special variables. Use the macro environment.
4:23:33
ghostyyy
pfdietz, are you supposed to just pass every function that you plan on using inside of the macro to it via macro arguments?
4:24:03
beach
Bike: Sure, but if it only uses standard functions, the standard prevents shadowing, as you pointed out.
4:24:28
Bike
yeah. i'm just saying, pretty much any macroexpansion has free variables. it's just not usually an issue in practice.
4:24:41
pfdietz
ghostyyy: one thing to remember is that when you compile code, the macros are evaluated at compile time, not when the code they are in is run. So if that code binds a variable later, it doesn't affect the macro at all. The macro is already expanded.
4:26:19
beach
ghostyyy: A macro that expands to the use of a globally defined function that is not standard, is typically defined in the same package as that function.
4:27:19
beach
ghostyyy: So to have an accident, client code would have to write (flet ((package::secret-function (....))) (macro-call ...))
4:27:30
Bike
it's like, i get that common lisp macros are dangerous in theory, and that hygenic macros are safe, but it just has not happened for me
4:27:47
Bike
i have never run into this latter situation in several years of programming and had to be introduced to the possibility by an academic paper
4:28:13
ghostyyy
it honestly has never really occurred to me that someone might not think macro hygiene is an important thing to have, but i guess if its not a problem you encounter often then it makes sense
4:28:57
beach
ghostyyy: Perhaps it does for newbies who don't know about GENSYM, but not for programmers with a bit of experience.
4:29:04
pfdietz
Or, if it does happen, there are so many more common ways to shoot yourself in the foot that it doesn't matter.
4:29:07
ghostyyy
in retrospect i do find it kind of amusing that people have done serious academic research on how to let people get away with shadowing basic operations like cons
4:29:45
ghostyyy
still, i do feel like its a good thing, just that it gives you a nice guarantee that nothing bad will happen, no matter how hard you try
4:29:46
pfdietz
You can shadow CONS in CL. You work in a package where the symbol CONS means something else.
4:30:20
beach
ghostyyy: It is a matter of compromise. The more such guarantees that the language can provide, the harder it gets to use it.
4:31:54
Bike
i do like the conceptual simplicity of it. macro function's just a function you call on some code. obviously you can do all kinds of horrible things in that framework, but programming is all about that anyway
4:35:43
drmeister
ACTION prefers a powerful language that doesn't come with airbags, training wheels and safety rails. Wheee!
4:41:39
pfdietz
In a large project those get added back, layered on top of the language as social restrictions to get a large group of programmers to work well together. Things like "thou shalt not use :: on any symbols in your code".
6:20:41
drmeister
This is generated by the DO* macro and I'm trying to track down where they are coming from
7:57:57
stylewarning
Are there any good tutorials about properly creating a new data type in Common Lisp? I feel as though many data types I create that are public facing are not all that good with respect to things like printing, readable representations/literals, FASL safety, etc.
7:58:50
stylewarning
It would be nice to have a checklist for creating a high quality user data type, be it a new class or structure.
7:59:24
phoe
stylewarning: I think the best idea is to start creating one, fill it with your ideas, post it here, gather comments, update the document, rinse, repeat.
8:00:19
stylewarning
Yeah I may do that. The impetus is to redesign CL-ALGEBRAIC-DATA-TYPE which is rough around the edges in terms of things like respecting print variables.
8:11:36
stylewarning
Maybe FASL safety is a poor term. What I mean is making sure your data structures can be dumped by having load forms and the like
8:45:07
beach
I do that by defining a reader macro `[', so that an object is represented as [package::class :initarg1 value1 :initarg2 value2 ..]. The reader macro simply reads the list and then does (apply #'make-instance list).
9:16:06
Shinmera
stylewarning: You should always provide a print-object method that prints it in a usable way, and possibly a describe-object method for detailed description.
9:16:39
Shinmera
stylewarning: make-load-form is only necessary if you expect it to be useful to use your object as a literal.
10:36:30
loke
Shinmera: isn't it important to use MAKE-LOAD-FORM if you have soemthing like (defconstant +foo+ (make-instance 'my-special-class))
11:45:58
MrMc
For my Bachelor Thesis I would like to write a common lisp library is eBay API worth the while
12:23:25
Colleen
drmeister: Shinmera said 1 hour, 38 minutes ago: https://www.reddit.com/r/Common_Lisp/comments/7twkk9/numerical_libraries_for_scientific_computing_in/
12:24:07
cess11
no, I mean that this company exposes about that many fairly open API:s. you'll probably want to decide which are interesting for your studies.
12:36:02
Shinmera
MrMc: Do you even have anyone that would supervise such a thesis? A professor that would accept and review it?
12:40:25
Shinmera
Not just that, you need to find someone, probably an assistant of the prof, to supervise you for the duration of the thesis. I heavily doubt you'll find anyone that knows Common Lisp, so I heavily doubt you'll find anyone willing to do that.
12:40:28
cess11
also, the others are more verbose and less hackish in their syntax, they are very easy to understand.
12:42:25
Shinmera
Besides, what you're proposing does not sound suitable for a thesis. How would it further science? What kind of prior research would you cite? How does this present anything new? A thesis is more than just implementing a piece of code.
12:42:39
cess11
usually there's something resembling a research question in a thesis, what would yours be?
12:45:03
MrMc
Something along the lines can a language standadised in the past millenium be used for eCommerce today
12:53:14
jmercouris
I got this error from uiop "Program args must all be simple strings", what is a simple string?
12:54:52
cess11
MrMc: if you were to search for something like 'common lisp ecommerce' you'll find some useful resources. if you choose a project you can express formally it will increase your chances of getting someone to grade it.
12:58:17
Shinmera
"If the result-type is a recognizable subtype of vector, and the object is a sequence, then the result is a vector that has the same elements as object. If result-type is a specialized type, the result has an actual array element type that is the result of upgrading the element type part of that specialized type. If no element type is specified, the element type defaults to t. If the implementation cannot
12:59:47
Shinmera
I mean I see no reason for it to not be simple in an implementation, but it doesn't seem guaranteed either.
13:16:27
Xach
jmercouris: i think uiop defers to whatever the implementation provides. on sbcl run-program uses execve.
13:17:04
jmercouris
https://github.com/fare/asdf/blob/master/uiop/run-program.lisp is full of +implementation flags
13:23:17
Xach
The answers are a few M-.s away, except asdf's many wrapping forms might jump you to the wrong place.
13:24:35
mercourisj
Yeah, I've been looking at run-program...I'd need to spend a little bit of time to understand it
13:41:01
pfdietz
(coerce <sequence> 'simple-string) will give you a simple-string, since the value returned by (coerce x y) is of type y.
13:44:50
KZiemian
Xach: I must left reading PCL for sickness of to much theory and to less programming
14:11:19
AeroNotix
PCL is imho the best book to learn CL imho. It doesn't put CL on a pedestal like a lot of books do. It treats the language just as a language. Rather than trying to put a halo of mythology around it.
14:12:53
dlowe
Honestly, it was the most amazing thing for a long time, but these days it's a solid middle-of-the-road language with a lot of history.
14:16:03
AeroNotix
Don't know about that. I use a lot of the new fangled languages and I still find myself thinking how much easier things would be in CL.
14:16:36
AeroNotix
literally the only thing I think CL doesnt have going for it is a good standardized concurrency model. there are good libraries which are portable but still.
14:43:34
AeroNotix
rumbler31: I just mean that in the CL standard it doesn't standardize any concurrency interface as far as I know (threads, actor model etc)
14:44:36
Shinmera
atomicity of operations and the memory model are good things to know for concurrency.
14:45:17
AeroNotix
Right and if CL specified a higher level interface for say, threads and related functionality (mutexes) a lot of the atomics are implied.
14:45:21
dlowe
Yeah, the newer languages all have their own scheduler and so far only CMUCL has done this (that I know of) and it wasn't amazing.
14:45:48
heisig
AeroNotix: sometimes I have the impression that concurrency is such a blurred topic, that maybe the best approach is to leave it outside of a language standard...
14:46:22
pjb
AeroNotix: on the contrary. For example some implementation (having threads), ensure atomicity of hash-table accessess while others don't.
14:46:33
AeroNotix
pjb: depends how you look at it. If it's parallel and you specify a mutex interface the implementation would require some level of atomicity
14:46:54
Shinmera
heisig: The problem with that is that it becomes very hard or impossible (under efficiency constraints) to write portable software.
14:47:03
pjb
AeroNotix: even setf of a variable is not always implemented atomicly (eg. on 64-bit machines with 32-bit data bus, you could end with botched data or references!).
14:47:34
pjb
AeroNotix: the alternative would be to have locks everywhere! It would be way to slow for most purposes.
14:47:38
AeroNotix
What I was meaning is that if there was a standardized concurrency interface a lot of those issues would've needed to be addressed.
14:48:40
pjb
On the other hand, the application developper usually know what his mutexes are, so he can add only the locks that are needed.
14:49:27
AeroNotix
Right, I agree with that approach. I wasn't meaning that (for example) setf would need to become atomic as part of the standard just that having a concurrency model in the standard that operations like setf would need to have their atomicity explained.
14:49:34
heisig
Shinmera: I know. On the other hand, standardizing on concurrency can also screw you at a later time if hardware capabilities change.
14:50:12
AeroNotix
pjb: I've had it said to me before that including a concurrency model in the standard would've been a bad idea. For example if green threads or the actor model was chosen and a new technology appeared and rendered it obsolete
14:50:26
rumbler31
well so... what, is the argument that languages that have concurrency friendly intrinsics may restrict implementation flexibilty?
14:51:03
pjb
AeroNotix: indeed. Imagine you're implementing CL on a GPU. You won't have the same problems at all as when implementing it on a CPU.
14:51:33
AeroNotix
Right. Perhaps if the API was described broadly enough #'EXECUTE-CONCURRENTLY or something. That doesn't imply any particular model.
14:51:48
pjb
At one time, processors didn't have cache memory and memory barriers. Now they all have it.
14:52:19
Shinmera
rumbler31: Yes, though that's only part of it. The other part is that the requirements by the spec may be too harsh or even wrong, affecting not just implementations but also users.
14:53:35
AeroNotix
yeah it'd be a poor experience if they added a model which only made sense at the time but was superseded by better technology today
14:57:32
dlowe
If it were abstracted with a nice interface, the implementation could use the better technology.
15:05:01
AeroNotix
sure, if you kept it generic enough the underlying implementation could be whatever you needed it to be. That said, some models would need primitives for model-specific operations
15:09:00
mgsk
How do I do something like this: https://gist.github.com/notmgsk/3204d1ce758dff6702b3389a33ecc5b0 I want START to begin at zero, and then increment it at the end of the loop
15:17:46
mgsk
Begin with start = 0, then at the end of the loop, set start to start = start + something
15:24:28
mgsk
dlowe: (loop for i in '(1 2 3) for start = 0 then (+ start i) do (format t "~D~%" start))
15:30:15
mgsk
dlowe: (loop for i in '(1 2 3) with start = 0 do (format t "~D~%" start) (incf start i))
15:36:24
mercourisj
Alright, so I have within my program something like (defvar some-system-path (calculate-default-path)), when I compile my lisp image, the path calculated on my machine is persisted into the image
15:37:03
mercourisj
I want this software to work on other users computers as well, so somehow I should defer (calculate-default-path) to when they launch the program
15:37:21
mercourisj
because my defvar is a top level form, I was thinking of writing a macro that does this, does this seem like a good idea or no?
15:38:09
mercourisj
a macro that will take something like (def-deferred-var var-name var-initialization-function), and var-initialization-function will be invoked on startup to setf some defvar
15:39:58
mercourisj
AeroNotix: Yeah, I was going to put them in a list of vars that will be iterated calling their initalization function
15:40:08
mercourisj
AeroNotix: Something akin to the approach for the defcommand macro which also maintains a list of commands
15:41:02
AeroNotix
mercourisj: is there no way your program could be refactored to not need the global defvar?
15:41:28
mercourisj
well, consider *global-map* for the global key map, I guess yes, technically it is possible, but it doesn't make sense
15:41:40
dlowe
yeah, but so is threading a super-common piece of data through each and every function
15:41:59
AeroNotix
mercourisj: not wanting to start a war but emulating emacs style is a bad practice. Elisp is a terrible lisp and perpetuates bad style