bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #commonlisp
bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #commonlisp
cinerion_ has joined #commonlisp
krjst has quit [Server closed connection]
cinerion has quit [Quit: WeeChat 3.7]
krjst has joined #commonlisp
occ has joined #commonlisp
dcb has quit [Quit: MSN Messenger 3.8]
anticomputer has quit [Remote host closed the connection]
anticomputer has joined #commonlisp
semarie has quit [Remote host closed the connection]
semarie has joined #commonlisp
bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #commonlisp
selwynning has quit [Server closed connection]
selwynning has joined #commonlisp
LispTyro_ has quit [Quit: Connection closed for inactivity]
vxe420_ has quit [Server closed connection]
vxe420 has joined #commonlisp
bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #commonlisp
Josh_2 has joined #commonlisp
<Josh_2>
Good Afternoon :sunglasses:
Cymew has joined #commonlisp
zxrom_ has left #commonlisp [Leaving]
mgl has joined #commonlisp
johnjaye has quit [Ping timeout: 260 seconds]
johnjaye has joined #commonlisp
dino_tutter has joined #commonlisp
euandreh has quit [Remote host closed the connection]
euandreh has joined #commonlisp
shka has joined #commonlisp
LW has joined #commonlisp
attila_lendvai has joined #commonlisp
cinerion has joined #commonlisp
Gleefre has joined #commonlisp
rainthree has joined #commonlisp
cinerion_ has quit [Quit: WeeChat 3.8]
habamax has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.2)]
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
attila_lendvai_ has joined #commonlisp
attila_lendvai has quit [Ping timeout: 258 seconds]
attila_lendvai_ has quit [Read error: Connection reset by peer]
attila_lendvai_ has joined #commonlisp
amb007 has quit [Ping timeout: 265 seconds]
amb007 has joined #commonlisp
<ogamita>
Josh_2: Hi!
<ogamita>
Gleefre: you can put a reader macro on all the available characters. Note: (loop for code below char-code-limit for ch = (code-char code) when ch do …) there may be holes (and they ARE holes with unicode). Only as I mentionned, in some implementations, it may be slow, ie. O(char-code-limit), to get the reader macros.
<jackdaniel>
thou shalt not make being beyond what necessary is -- yoda (probably)
alcor has joined #commonlisp
attila_lendvai_ has quit [Ping timeout: 258 seconds]
ec_ has quit [Ping timeout: 240 seconds]
ec_ has joined #commonlisp
attila_lendvai has joined #commonlisp
AndrewYu is now known as Andrew
<Gleefre>
ogamita: Sure it is possible, but it will be slow because of huge amount of macro characters + it will shadow all other reader macros :/ Also it is too much for a simple idea
<Reinhilde>
huh...
attila_lendvai has quit [Ping timeout: 252 seconds]
<jackdaniel>
package local nicknames are rather cheap, and I'd risk saying that they'd be cheaper than potentail symbol aliases, so even for one symbol it'd be better to make a package alias
<jackdaniel>
also imo it would be prohibitively confusing to have two printed names for the same symbol
<Gleefre>
Well, same may be applied to packages to some extent
<Gleefre>
They also have names and nicknames
<Gleefre>
And now even local nicknames
<Gleefre>
But sure, for now it is nothing more than an idea with no understanding how easy/hard to implement it would be
<jackdaniel>
I don't see it that way (but that may be a bias:)
<jackdaniel>
well, PLNs are implemented in a way, that reader first looks for the package name in local nicknames, and then in global package names (more or less)
<jackdaniel>
symbol local nicknames would probably work in a similar fashion (you'd have two dictionaries)
<jackdaniel>
package local symbol nicknames*
ec_ has quit [Ping timeout: 240 seconds]
johnjaye has quit [Ping timeout: 246 seconds]
ec_ has joined #commonlisp
<Gleefre>
Well, I might be seeing non-existent duality between packages and symbols, sure...
johnjaye has joined #commonlisp
<Gleefre>
It is just that syntax is package:name, not something like package->name
<jackdaniel>
OK, the mistake in c2call-stack was a silly one (and that's good, not trickery involved)
pve has joined #commonlisp
dino_tutter has joined #commonlisp
dcb has quit [Quit: MSN Messenger 3.8]
Brucio-61 has joined #commonlisp
<pve>
Gleefre: I'm still not really clear on what was wrong with the eclector approach.. it seems to me that for all intents and purposes, it gives you pretty much exactly what you are asking for (with super low effort at that). Maybe I misunderstood, or perhaps you're looking for an ultimate general solution.
rpx has joined #commonlisp
<Gleefre>
pve: eclector approach is fine, but to use it you must enable it in every file where you want to use it
<Gleefre>
I don't really know what I am looking for
<pve>
you should probably bake it in to your own in-package macro
<pve>
or some other "header"-type macro
<Gleefre>
I don't think what I'm looking for can be implemented as a library
<Gleefre>
But more of an extension
scymtym has joined #commonlisp
<pve>
Gleefre: I mean something like (gleefre:in-package :my-package) ; <- eclector is enabled here
<Gleefre>
That sure would work, but again, for internal (to my library) use only
<Gleefre>
Like you won't be able to make an alias and then export it
<pve>
or perhaps better as a standard in-package and a separate (enable-symbol-aliases) macro
chomwitt has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
karlosz has joined #commonlisp
<pve>
Gleefre: well you could export my-library:enable-symbol-aliases which the client can use, or the client can set up their own aliases as they see fit. I think the latter is perhaps a more sensible approach, just let the user of your lib set up whatever they need, package-local-nicknames or symbol-aliases or something else.
<pve>
Is really your job to set up the perfect aliases for your lib? Many users might disagree and override them anyway..
pranavats has left #commonlisp [Error from remote client]
<Gleefre>
Well, it is not just about libraries and creating aliases
<Gleefre>
It is just that it is annoying that you can't rename a symbol in any way
<Gleefre>
The closes is to create a symbol-macro, which doesn't always work
<pve>
well, in any case, it's great if it fixes your problem
<Gleefre>
I mean, it doesn't really
<Gleefre>
It just shows what I'm talking about
<Gleefre>
This exact hack has some issues for sure, but wouldn't it be nice to be able to rename symbols?
<Gleefre>
(Or rather creates additional names)
<pve>
Is it a matter of convenience? Doesn't sound like it's going to let you "10x" any problems..
<Nilby>
what's wrong with setf fdefintion? you can even have a defun* which updates with (get 'foo :other-names)
<pve>
Or about having the power to do so, in case it's ever needed?
<Nilby>
Maclisp defun would store the previous definition so you could undefun
<Gleefre>
It is a matter of convenievce, sure.
<Gleefre>
Like package nicknames
<Gleefre>
setf'ing fdefinition doesn't really solve all problems
<_death>
sublis solves all problems :)
<Gleefre>
And when you need to have to a different thing (fdefinition / symbol-macro / ... ) for each type of symbol, and you need to use some custom defun*, it complicates things a lot
<Gleefre>
_death: How?.. In a global macro wrapping whole file?
<pve>
Gleefre: do you need a custom defun to achieve that?
<Gleefre>
You need if you want to update fdefinition
<_death>
Gleefre: before How I'd ask What and Why.. to me such aliasing is not appealing (and that also goes for PLNs, though I can imagine some scenarios where even I would consider using them, but in practice never found the need)
<Gleefre>
Also you probably won't be able to "link" symbol-plist's
<pve>
Gleefre: Wouldn't it be better to be explicit? Standard defun, and then an (alias 'foo 'bar) somewhere.
<Gleefre>
That works when you don't redefine the function
mason has quit [Server closed connection]
mason has joined #commonlisp
random-nick has joined #commonlisp
<Gleefre>
But when you're developing something for example, and you add something to a function and redefine it
<Gleefre>
And to test it in a repl you might want to link a shorter name to it (if it is a long long name
<pve>
you mean if you C-c C-c instead of C-c C-k?
<Nilby>
the repl almost always types it for me
<Gleefre>
pve: Yes, bacause you don't always recompile the same file
<Gleefre>
*the whole file
<Gleefre>
And the repl might not be able to autocomplete always, for example if there are multiple functions with same prefix
<pve>
the real function could have the short name, and the alias could be the long name :)
<Gleefre>
Of course it is not that slow, but still annoying to type
<pve>
but really, you should have a hotkey somewhere that reloads you entire system
<Nilby>
history completion
<Gleefre>
pve: But what if you develop a game and need to change current state right now without opening it again? :/
<Gleefre>
Interactive development is important, when you don't need to reload the whole system
<pve>
i didn't mean kill slime, just load-system
<Gleefre>
But that will reset global state of my game :/
szkl has quit [Quit: Connection closed for inactivity]
<Gleefre>
I mean, it is just super annoying that for example in python you can do "from math import factorial as f"
<_death>
you can use a more sophisticated completion system, that can expand say "m-v-b" to "multiple-value-bind", or something like dabbrev-expand
<Gleefre>
But in CL you can't
<Gleefre>
_death: completion system just masks the problem, and I doubt it can mask everything
<Gleefre>
Like, you can expand m-v-b
<Gleefre>
But what if you have just a very long function name with -?
<Gleefre>
Like rhombihexadeltillep
<jackdaniel>
don't get mer wrong, but this really looks like seeking a problem for a solution
<jackdaniel>
if you have an operator, you may always define a macro, if you have a variable, you may define a symbol macro
<_death>
so if you find yourself in such a specialized situation, a simple defalias facility may work.. or some slime contrib
<pve>
Gleefre: you would type "rhtp" (or something) and do fuzzy-completion
<Nilby>
i use history completion, which can put in the most recent things you type string with "rhom" and something like dabbrev-expand which can grab stuff from anywhere it's seen, but really (defalias 'f 'math:factorial) and just relaias if you need to
<jackdaniel>
and in principle you could find some made up example where it could be useful, but is that edge case really something you use daily?
<Gleefre>
I mean, you can do everything without such ability
<pve>
Gleefre: also my life would be ruined without dabbrev-expand, I've had it bound to the button above TAB for years
<Gleefre>
But then you can do everything on turing comlete language
<Gleefre>
Maybe that has some problems, but right now I don't really see any
<jackdaniel>
Gleefre: I'm not putting in question a theoretical usefullness of such utility, I'm putting in question its practical usefullness
<Gleefre>
Well, it will allow :import-as
<jackdaniel>
usefulness*
<_death>
what I would find annoying is to look at a file and see the equivalent of a:foo and now I have to chase the pointer to find out that it's really zs3:foo
rendar has quit [Ping timeout: 240 seconds]
<Gleefre>
iirc M-. will take you to the symbol definition, no?
<jackdaniel>
fwiw counts as chasing
rainthree has joined #commonlisp
<Gleefre>
I am pretty sure I'd chase for both a:foo and zs3:foo
<pve>
Gleefre: You know, chances are that 6 months from now, you're not going to consider this a problem anymore, because you found a different way of doing things that is superior to your old way of doing things.
<pve>
That has happened to me more times than I care to admit, and it's always embarassing when I realize my sillyness.
<pve>
(I don't see it stopping anytime soon :)
rendar has joined #commonlisp
rendar has quit [Changing host]
rendar has joined #commonlisp
<Gleefre>
pve: Well, this old way is bugging me for 2-3 years already, at least
<Gleefre>
I didn't really need it, but I sure wish it was possible
<Nilby>
pve: Exactly. I wrote aliasing stuff (and many other such silly things) and then never used it.
<Gleefre>
I would say that aliases don't really solve the problem
<Gleefre>
They are not perfect
<pve>
Gleefre: Then take one of the 80% solutions suggested here, and *actually* try to use it. You might quickly see that you didn't actually need it, or that the real problem was something else.
<pve>
with a completely different solution
<pve>
because spending a lot of time building a 100% procent solution and then never needing it is kind of a downer :)
<Gleefre>
None of these solutions are intergrating well with, for example, defpackage
<Gleefre>
I really want to have something that is easy to use
<Gleefre>
So I guess I will write a prototype as patched sbcl, and see how it goes
<Gleefre>
Even if I won't use it (but I probably will because there are a lot of long names in libraries and at least in a REPL session it would be nice)
<Gleefre>
The closest solution is probably using eclector (and it is really cool), but it requires an extra step turning it on as well
Catie has quit [Ping timeout: 268 seconds]
rpx has joined #commonlisp
<pve>
Gleefre: you could be using that *today*, and all that's required is one extra form, and then you'd know if you're on the right track
<pve>
Gleefre: btw, which slime completion method are you using?
<Gleefre>
Ugh
<Gleefre>
I didn't really start configuring emacs yet
<pve>
so not fuzzy completion, I take it?
<Gleefre>
I used portacle until recently
<Gleefre>
And then tried to emulate it in my config
<Gleefre>
So I do have (setq slime-company-completion 'fuzzy)
<pve>
Gleefre: so completing "pkg" gives you "package" and "mvb" gives you "multiple-value-bind"?
Gleefre has quit [Remote host closed the connection]
Gleefre has joined #commonlisp
<Gleefre>
pve: it does (even though it opens another buffer :/)
<Gleefre>
Nilby: I'll take a look, thanks
<alcor>
AFAIK, Python's "from x import y as z" just adds a ('z' : <function>) entry to the globals() dict, which is equivalent to setf'ing an fdefinition.
<Gleefre>
Well, python doesn't really have symbols and it has some issues reloading libraries iirc
<pve>
Gleefre: and the buffer is called "*Fuzzy Completions*"?
<Gleefre>
pve: yes
<pve>
ok
Josh_2 has quit [Ping timeout: 240 seconds]
rainthree has quit [Read error: Connection reset by peer]
<Gleefre>
alcor: Also, I'm not sure it is exactly true - it probably has different effects depending on definition in the library (module?..) -- since you also can export global variables (from math import pi as PI)
<alcor>
Python symbol lookup is just a cascaded dictionary lookup in locals(), globals(), with an extra lookup in globals().__builtins__ for the builtins
<Gleefre>
Well, it is enough in python because you don't reload libraries I guess
<Gleefre>
But reload the whole program instead
<Gleefre>
But yeah, from math import factorial as f; import math; math.factorial = math.sin -- and math.factorial and f are not the same
<Gleefre>
But in CL that won't work that well because redefinitions are well supported
<alcor>
Isn't this normal behavior? Redefining a definition doesn't affect any existing bindings. The retain their values prior to the re-definition.
<_death>
there are approaches that extend the repl to avoid too much typing, like in gbbopen (I think allegro also has something similar, and sbcl has an sb-aclrepl contrib).. I'd prefer those to a "symbol renaming/aliasing facility"
<Gleefre>
alcor: Alias shouldn't be seen as a binding
<Gleefre>
More like symbol-macro, but not just for variables
<alcor>
Gleefre: In that case, adding a layer of indirection by wrapping the function with a proxy function (that just forwards arguments) could work.
<alcor>
The proxy function is there just to force the symbol lookup
<Gleefre>
Again, it makes things complicated
<Gleefre>
With great care - sure, you can create an alias
<Gleefre>
But then you will also need to consider CLOS classes / structures, plists, ...
<alcor>
Aliasing names in a dynamic language where names can be rebound at any time isn't simple, I agree.
<Gleefre>
Also what if it is a keyword like for in loop?
<Gleefre>
Or if it is a flet introduced by the library's macro
<alcor>
Is there a system where this problem is solved elegantly?
<Gleefre>
Creating a link can be much simpler if it was converted at the read time
<Nilby>
If it's typing long things you're concerned about, REPL hacks make it better.
<Gleefre>
Not just typing long things.
<Gleefre>
It is also might help readability
<Gleefre>
Or you could translate standard symbols into another language (more like for teaching purposes, but still)
<Gleefre>
alcor: I don't know, but would be interested to know...
rainthree has quit [Read error: Connection reset by peer]
rainthree has joined #commonlisp
mgl has quit [Quit: Client closed]
azimut has joined #commonlisp
bjorkint0sh has quit [Quit: Leaving]
bjorkintosh has joined #commonlisp
bjorkintosh has joined #commonlisp
bjorkintosh has quit [Changing host]
<pjb>
Gleefre: Already, use defalias and define-symbol-macro and see how far you go with that. You can define a localized cl package The only limitation for a trivial implementation is CL:NIL = false. You could (defconstant FRENCH-CL:NUL CL:NIL) but for (SI (PAIRP 3) 'oui 'non) PAIRP would have to return FRENCH-CL:NUL = CL:NIL, not 'FRENCH-CL:NUL which is true in CL.
<pjb>
This is a very small restriction.
<pjb>
And anyways, for reasons such as debugging, error reporting, etc, you don't want pure aliases. (first 42) and (car 42) are the same thing, they could be implemented as the same function, but this would give bad error message. Having two different functions (or wrappers), let you see in the backtrace and error messages that FIRST got a non-list, or CAR got a non-list.
<Gleefre>
As I mention earlier, you won't be able to translate loop keywords for example
<pjb>
So it's better to have wrapper (defonc premier (x) (first x)) and have error messages name premier.
<Gleefre>
As for backtrace - that is a problem... Hm...
<Gleefre>
You will need to parse the loop yourself
<pjb>
Gleefre: in particular, LOOP keywords are not interned symbols! They're symbols used for their name! That's why you can write (loop for …) as wel as (loop :for …) or (loop cl-user::for …) etc.
<Gleefre>
How do you know which "for" is a keyword and which is a variable?
<pjb>
syntax.
<Gleefre>
Sure, if you use :for or #:for, it can be easier to do
<pjb>
No, you have to accept all cases anyways.
<Gleefre>
Then you do need to parse all loop clauses yourself
<pjb>
(loop with fors = '(for for for) for for in fors collect for) #| --> (for for for) |#
<pjb>
Yes.
<Gleefre>
Which is at least not trivial
<_death>
Gleefre: loop was designed with english in mind.. if you want localization, you need to do localization work
<pjb>
Just copy-and-paste the syntax from the hyperspec to a parser generator.
<pjb>
trivial.
<Gleefre>
You already need to use a parser genrator
<pjb>
Gleefre: yes, _death raises an important point, loop french syntax could have keywords or clauses in a different order than english syntax.
<Gleefre>
Well, in case of loop - sure
<pjb>
(boucle pour i de-type petitentier de 1 a 10 pas 2 collecter (* 2 i))
<Gleefre>
Sure, localisation might is not just about aliases, but still is easier with them
<Gleefre>
Another example would be (declare ...)
<Gleefre>
You will need to reparse declarations in every form that accepts them
<Gleefre>
And then alexiandria's parse-body won't work anymore
<_death>
(loop (print (eval (sublis-magic (read))))) .. similar could be done for LOAD
<pjb>
Gleefre: well, (declare (inline premier)) at least it wouldn't cost you anything compared to first.
<_death>
now, you may want a nastier sublis that goes into atoms like vectors or instances..
jfb4 has quit [Server closed connection]
jfb4 has joined #commonlisp
occ has joined #commonlisp
random-jellyfish has joined #commonlisp
boigahs_ has quit [Server closed connection]
<_death>
pve: so, do you now have lisp meetups in porvoo?
boigahs has joined #commonlisp
<pve>
_death: oh, not yet. Unfortunately I don't work quickly :)
<pve>
would like to make it happen though
<pve>
I'm not sure they would be lisp-specific, the town is probably too small for that
<_death>
pve: ah.. msg me if you do this summer, I might show up ;)
<pve>
hey nice, will do
pranavats has joined #commonlisp
<pve>
_death: also if you decide to visit regardless, let me know so we can at least grab a beverage/lunch if I'm in town :)
<_death>
sure
random-jellyfish has quit [Quit: Client closed]
parjanya has joined #commonlisp
tyson2 has joined #commonlisp
rendar_ has joined #commonlisp
tibfulv has quit [Remote host closed the connection]
rendar_ has quit [Client Quit]
tibfulv has joined #commonlisp
habamax has quit [Remote host closed the connection]
rpx has quit [Quit: Client closed]
Guest5402 has quit [Ping timeout: 250 seconds]
ryanbw1 has quit [Ping timeout: 255 seconds]
dino_tutter has quit [Ping timeout: 260 seconds]
dlowe has joined #commonlisp
phadthai has quit [Server closed connection]
phadthai has joined #commonlisp
travis has joined #commonlisp
lucasta has joined #commonlisp
Cymew has quit [Ping timeout: 252 seconds]
usop[m] has quit [Remote host closed the connection]
zxcvz has joined #commonlisp
zxcvz has quit [Client Quit]
jryans has quit [Remote host closed the connection]
CodeGerrard has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
CodeGerrard has quit [Quit: Quit]
Algernon69 has joined #commonlisp
LW has quit [Quit: WeeChat 3.8]
chris42 has joined #commonlisp
Algernon69 has quit [Quit: Leaving]
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
ec_ has quit [Ping timeout: 240 seconds]
ec_ has joined #commonlisp
chomwitt has quit [Read error: Connection reset by peer]
euandreh has quit [Quit: euandreh]
dcb has joined #commonlisp
amb007 has quit [Ping timeout: 265 seconds]
amb007 has joined #commonlisp
tertek has quit [Server closed connection]
Gleefre has quit [Remote host closed the connection]
Gleefre has quit [Remote host closed the connection]
Gleefre has joined #commonlisp
Catie has joined #commonlisp
rainthree has joined #commonlisp
NotThatRPG has quit [Read error: Connection reset by peer]
Catie has joined #commonlisp
Catie has quit [Changing host]
lucasta has quit [Remote host closed the connection]
NotThatRPG has joined #commonlisp
NotThatRPG has quit [Ping timeout: 258 seconds]
tyson2 has joined #commonlisp
rgherdt has joined #commonlisp
kevingal has quit [Ping timeout: 246 seconds]
<alcor>
What happens if CLOS instances are used as keys in a hash table? Does the table used the object id/pointer as a hash, like in Python?
<bike>
yes. if you look at the definitions of eql, equal, equalp, you'll see that on standard objects they all just use eq. and hash tables are defined in terms of those comparisons.
NotThatRPG has joined #commonlisp
chris42 has quit [Quit: Client closed]
<alcor>
A hash function is needed too though.
<alcor>
eq/eql/equal are equality predicates, but the hash table also needs a hash function. And I'm wondering if the hash function for complex objects (e.g. CLOS instances, vectors, lists) is specified somewhere.
<bike>
The semantics are defined in terms of the quality predicates. A hash function is an implementation detail.
<bike>
the equality predicates*
<bike>
there's also sxhash available, but the hash tables don't have to use it
<alcor>
So the standard hash table just works with CLOS objects as long as the :test is 'equalp? Does it just hash the instance slots?
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bike>
That's not what I said. Hash tables with any of the four tests will behave the same on standard objects, because (eql x y) = (eq x y) when x and y are standard objects, and similarly with equal and equalp.
<alcor>
True. Okay, I understand. CLHS http://clhs.lisp.se/Body/f_equalp.htm says that equalp only does a recursive comparison for structures. For "other objects" (e.g. CLOS instances), it is equivalent to `eq'.
<alcor>
Okay, that's a bit irritating. Seems like the standard hash table can't be extended to support value-like CLOS classes :/
<pve>
alcor: Can you create a function that maps your instances to suitable keys?
<Nilby>
Testing equality of arbitrary complex generic objects, one is force to make some compromise, so instead of doing a half-assed job, Common Lisp leaves it up to you to define.
<alcor>
Yes, but `make-hash-table' does not allow passing a custom equality predicate. It only seems to accept eq/eql/equal/equalp.
<pve>
alcor: by "suitable" I meant keys that will work with one of the predicates accepted by make-hash-table
<alcor>
pve: Ah, okay, you mean something like a "synthetic key", where the synthetic key is hashable & equality-comparable
<bike>
some implementations (e.g. sbcl) allow custom hash table predicates, as long as you also provide a hash function
<Nilby>
e.g. sb-ext:define-hash-table-test
<pve>
alcor: yep, #<customer> => "John Smith, 1958-02-15" or something
<pve>
maybe accompanied by some nice lookup functions?
<alcor>
pve: That works of course, but I was hoping to avoid it.
<Nilby>
The standard hash tables a pretty minimal, I suppose to ease the burden on implementors. Supporting user defined hash functions and weakness are common extensions. But there are even more fancy things, like concurceny guarantees, that one might like.
rainthree has quit [Ping timeout: 252 seconds]
<pve>
alcor: well I think it's a rather nice approach
<alcor>
pve: Synthetic keys + Wrapping the table is the common way to do it in ECMAScript, but it's a bit of boilerplate
<ixelp>
GitHub - metawilm/cl-custom-hash-table: Custom hash tables for Common Lisp
<alcor>
It uses the implementation-defined extension (if available), or falls back onto a custom implementation
<alcor>
But I'm not very happy about the interface (which seems to use code walking)
mikko has quit [Quit: WeeChat 3.8]
<pve>
alcor: Hmm, what's the boilerplate? If the function that maps your instances to keys is generic, wouldn't you implement this only once?
<alcor>
pve: You're right, it's much easier with generic functions 💡
<alcor>
What if we take this a step further. Is it possible to define a generic function that creates an appropriately-configured hash table based on the given class?
<alcor>
something like (make-hash-table-for 'my-class-name)
<pve>
yea I think so, with a sensible default for convenience
tyson2 has quit [Remote host closed the connection]
<alcor>
Since CLOS classes aren't objects, it seems we have to specialize on the symbol in this case
<pve>
alcor: although you might want to use a prototype object as the argument
<alcor>
pve: Also possible, but there's no guarantee that the instance exists at the time the hash table is constructed
<alcor>
specializing on the prototype requires a prototype object
<pve>
so you can define a method for symbols that basically does something like (make-hash-table-for (closer-mop:class-prototype the-symbol-naming-my-class))
<pve>
or however you get your instance
<alcor>
Never used closer-mop:class-prototype before. But this is a nice use case for it.
<alcor>
Thanks pve++
<pve>
alcor: no problem, lemme know how it goes
NotThatRPG has joined #commonlisp
<pve>
I suppose you could also do (allocate-instance my-class) to get a "prototype"
Noisytoot has quit [Server closed connection]
Noisytoot has joined #commonlisp
<alcor>
I think (class-prototype 'class) communicates intent better, i.e. the fact that the instance is merely used as a prototype for dispatch purposes and is not a real instance.
<alcor>
In Julia (another language with multiple dispatch), you can dispatch on Type{T}. I was looking for something similar, but the prototype trick is a cool alternative.
<pve>
you mean it dispatches on the *class* and follows the inheritance hierarchy?
<alcor>
Yes
<pve>
so Type{Foo} will get Type{T} behavior by default, unless overridden?