freenode/lisp - IRC Chatlog
Search
18:36:17
shka_
Xach: btw, can you take a look and say if it displays fine? https://sirherrbatka.github.io/cl-data-structures/l_1.html#812753871995231275
20:14:09
dlowe
is there a library or implementation feature that allows for asserting that only one reference is held to a particular object?
20:16:07
Bike
dlowe: kind of hard to define, or to know that it's true given everything that happens under the hood
20:16:28
Bike
for example, if you write a defmethod, machinery is gonna keep the original arguments around for (call-next-method)
20:17:32
dlowe
if it's hard for a function, it's even harder for the poor human trying to figure it out
20:21:47
dlowe
so a gc in its reaping or copying phase comes across something that really-should-be-garbage but isn't, it can signal an error or comething
20:27:44
phoe
I don't know if I can use this tool properly though and if it does what I think it does
20:56:39
mseddon
dlowe, I appreciate your pain, and thanks for both your and phoe's insight into observing this
20:59:19
mseddon
Please do report back how complete it's coverage is. It's at least conservatively great.
21:01:46
dlowe
mseddon: I would have to manually add (garbagify <object>) calls everywhere to figure out coverage
21:05:39
phoe
an error, what do you mean? that you want to signal an error if a given object is alive?
21:06:41
phoe
a minor issue is that the SBCL GC runs in the C world, you'll need to jump back to Lisp... which will be troublesome because the world is stopped during GC
2:41:31
Alfr_
dbotton, even (defconstant foo 12) (setf foo 13) doesn't need to trigger an error. It's only undefined behavior.
2:42:33
aeth
implementations are afaik permitted to add a (declare (whatever foo)) if they wanted to
2:48:00
dbotton
is there a reason why the standard felt the need for a deconstant but not on a local basis?
2:48:11
aeth
I don't think there's a way, but (declare) is valid so if you had to do (let ((x 1)) (declare #+your-cl (immutable x)) (setq x 10)) you could still write perfectly portable code here.
2:49:22
aeth
(and I think they're supposed to ignore unrecognized forms inside of DECLARE, so I think but am not sure, that that would just be a warning if you didn't do that)
2:51:51
aeth
Anyway, that's probably my guess as to why it's not in the standard. Because they probably anticipated that they didn't create an exhaustive list of useful declarations
2:59:09
aeth
dbotton: Sorry, what I mean is I don't think there was a particular need to include this in the standard since it gave implementations the power to add it, and they probably weren't really thinkinng about this sort of thing 30 years ago.
3:00:16
aeth
dbotton: You could also, yourself, create a macro that does this without even code-walking, since DEFCONSTANT exists. Just symbol-macrolet
3:02:11
aeth
dbotton: So I guess there is a way to mark a variable as a constant if you're willing to have a hidden DEFCONSTANT variable
3:10:20
aeth
dbotton: probably depends on the implementation because it says it's undefined in the spec, but it's an error in SBCL. e.g. (defconstant +foo+ 42) (defun foobar () (symbol-macrolet ((foo +foo+)) (setf foo 43)))
3:15:29
aeth
it solves the specific problem, but not the general problem, so maybe it's good enough depending on the task
3:20:24
aeth
dbotton: Sorry, I realize I didn't directly answer your question. It's a compile time error because it's an error when I DEFUN, which won't call the code directly
3:26:10
Bike
not really. the compiler can just determine if a variable is immutable by looking at how many places it's assigned.
3:27:51
aeth
the symbol-macrolet to a defconstant should produce the same code in an optimizing compiler (SBCL at the very least)
3:28:42
aeth
If you want more, you'd want an immutable type so it can be optimized outside of a function's scope, too.
3:38:10
dbotton
I have not yes started on clos, so sorry if this is ignorant, would it be possible to extend a built in type and then declare type it on the new type?
3:39:36
aeth
The thing itself always has a type, and the binding can have a type if DECLAREd (technically, it always has it, but it's normally T).
3:40:28
aeth
So the type declaration doesn't have an impact on the object itself, except that it might error if it mismatches (and it might not... only CHECK-TYPE guarantees the type error)
3:42:54
dbotton
I realize this is probably the wrong though process to start with for Lisp, ie trying to type the variable not the data
3:43:03
aeth
For the other part of your question, afaik, you normally can't extend built-in types, but sometimes you can, such as trivial-gray-streams or trivial-extensible-sequences
3:43:43
beach
dbotton: I think you are right. It is common for people coming from other languages to overuse type declarations.
3:44:12
aeth
Generally, type declarations should only matter if for arrays/vectors, numbers, and arrays/vectors of numbers
3:44:36
aeth
At least as far as performance is concerned. Otherwise, the added checks might actually deoptimize the code.
3:45:15
beach
dbotton: I read somewhere that languages with manifest typing force the programmer to come up with types that may not be true later on in the development process.
3:49:47
beach
dbotton: yes, you came to the right place since you can do arbitrary computations at compile time.
3:50:07
aeth
You can force someone to win a (complete, graphical) game before the code compiles if you want to. Just put a call to launch the game in an EVAL-WHEN.
3:50:59
dbotton
In Ada it is all about using the Type to insure correctness of code, a form of compile time computing that has worked very well for me
3:52:01
dbotton
I think once I have fully groked the CL approach will open something open in the avenue more
3:52:10
beach
dbotton: I am curious, then, as to why you want to use Common Lisp, and why you are trying to do the same things with Common Lisp that you have been so successful with using Ada.
3:53:35
dbotton
I have a lot of experience with C/C++ other languages as well, the Ada approach worked well, but realized I never actually learned lisp all these years
3:54:27
beach
dbotton: Then I seriously suggest you try to use it as it is normally used, rather than trying to emulate the Ada programming style with it.
3:56:53
dbotton
few other reasons interested me in lisp, age of standard, number of implementations available, quality of tool sets etc
3:57:16
aeth
dbotton: imo, there's a bit of a tension in Common Lisp between interactive development and compile time computation... both are more of a priority in CL than in most languages.
3:57:33
aeth
Interactive development means you can redefine things and you want to be able to have fast compilation times.
3:58:44
dbotton
My approach for my personal projects has been a very lisp like one even the Ada very ridged
3:59:35
dbotton
But being forced in to the type model has also improved the quality of the results I think
4:00:48
no-defun-allowed
A dynamic approach might be better if, by the time you would come up with a model to show correctness with, it wouldn't reflect on your current requirements. And there aren't any type systems that I know of that will let you migrate state from one model to another like in Common Lisp.
4:04:43
dbotton
beach, the other reason for the switch is Ada is now for all intensive purposes a one vendor product and they have more or less specialized in one niche
4:10:07
dbotton
These days I make my living for the most part outside the computer world so I can "afford" to invest in something more then job easy languages also
4:10:28
no-defun-allowed
In my probably significantly shorter experience with Lisp, the SBCL compiler catches type errors (on functions involving inbuilt types), or I can provoke them by poking at them with a REPL in about a minute.
4:10:54
no-defun-allowed
Though I heard Ada also has some more in terms of formal verification tools than other static languages.
4:12:52
beach
dbotton: For compile-time computations, I recommend the book "On Lisp" by Paul Graham.
4:13:10
aeth
There's no reason why there couldn't be a CL with even more static verification than SBCL
4:18:53
no-defun-allowed
Oh, also note that if I find an error like that, the thread that signaled an error pauses and I'm presented with a backtrace and some restarts, which usually suffice to test a solution without stopping the program. That is mostly non-present in most dynamically typed languages (I hesitate to call them "dynamic languages"), which makes them the "worst of both worlds", as they are apparently unsuitable for static
4:25:26
dbotton
So to sum up, interests are the general approach to development is like what I have used for years, the tools are there, the quality of tools is there, the quality of community supporting the tools is there, the language is ideal for my current interests in general ie compile time computing, and believe Lisp a good long term host for my creative
4:26:18
dbotton
the only negative, and probably singe reason never looked in to it, the readability of it
4:26:54
dbotton
I stumbled on Ada because felt that recording my ideas in a human readable language a good idea
4:27:25
no-defun-allowed
I never found precedence rules particularly friendly, but it's open for debate if I'm a "human".
4:27:26
dbotton
and it is the most readable of any language with a good modern toolset and at the time looked promising
4:29:41
dbotton
thank you all though for the direction and knowledge, still have much more to go before can similarly contribute
4:30:02
no-defun-allowed
Like, in mathematics classes I'd have written out long equations that weren't in a nice form, and couldn't parse it later. Then everyone else tells me that parenthesised prefix notation is harder.
5:40:40
dbotton_
interesting p17 of lisp 1.5 manual has discussion of making constants. I assume technique wouldn't work with current implementations
5:44:36
dbotton_
(I know 1.5 not CL but for me need to understand the why's and that comes from history)