freenode/#lisp - IRC Chatlog
Search
19:16:04
Colleen
Bike: drmeister said 13 hours, 54 minutes ago: I disabled cl:row-major-aref and cl:row-major-ast temporarily
19:21:08
jmercouris
I'm trying to add hooks into my program, I was thinking about making them exist for every defined-command (user invokable defun)
19:21:51
jmercouris
another thought I had was creating some macro like (define-hook :hook-name) that you can place inline, and any things registered to :hook-name will be invoked after that line of cod
19:23:02
jmercouris
the only issue with (define-hook) is that as it may be within a defun body, it won't be a top level form so (defun register-to-hook (function hook) ...) may not necessarily be able to register against a non-existent hook
19:23:36
jmercouris
though I guess that register-to-hook may make a binding for the hook if it does not exist, and then (define-hook) will just use that hook
19:27:36
phoe
client code can either push to the toplevel value of *something-hooks* for a global effect or rebind that for a dynamically scoped effect
19:28:41
jmercouris
the question was about how will users declare new hooks and register where the hook gets invoked
19:29:00
jmercouris
what if I want to add more logic down the road in what happens during a hook declaration
19:30:10
jmercouris
so that number could grow out of control and I may need to do some magic down the road
19:31:31
phoe
somewhere in code that opens a new tab, (mapc #'funcall (gethash :on-new-tab *hooks*))
19:31:42
dlowe
so, I have a hook mechanism in tcl I did myself. The things you'll want to do: have two identifiers for the hook - the hook trigger and a descriptive id
19:32:47
dlowe
so that (define-hook connected foo ...) will replace the foo proc in the connected hook
19:33:44
phoe
so if your hook is (lambda () (print "haha")) then the print will happen 10 times in a row.
19:34:30
phoe
that's why dlowe introduces a second identifier, so you can identify hooks by *their* identifier and replace them instead of pushing new ones.
19:35:31
dlowe
you can mess about with order inside the hook list, but if you want an abstraction layer that supports redefinition, the numeric priority is the way to go
19:36:56
jmercouris
I don't think i'll worry about priority just yet, that seems to be a more sophisticated problem
19:37:18
jmercouris
and then it could automatically calculate the order in which hooks should be invoked
19:38:20
_death
in my opinion, the function running the hooks should first copy the list and use that copy.. so that actions can change the list without issue
19:39:08
jmercouris
if it makes a copy of that list, why would it matter if actions change the list?
19:39:10
dlowe
in my hook implementation, hook functions can modify the argument list for successive functions or break out of the hook completely
19:41:08
_death
hook is a symbol that names a special variable.. (defvar *my-hook* '()) (add-hook '*my-hook* 'some-function)
19:41:16
jmercouris
dlowe: no way, I mean the trees are far and more complex, I'm just thinking, that either solution right now is not important for a first round implementation
19:41:40
jackdaniel
not sure if it fits your problem, but is a very interesting approach to propagating events
19:42:51
_death
there are more elaborate libraries for hooks, but this implementation suffices for what I need
19:43:20
jmercouris
_death: seems clean, I'll do something similar, but introducing the list that phoe and I spoke about
19:45:22
jmercouris
thank you all for your feedback, I'll have to spend sometime thinking about while not exhausted, and hopefully I'll have an implementation soon, and then my first version of hydra :) (https://github.com/abo-abo/hydra) for next
19:46:13
jmercouris
_death: right, which is why I was saying I wanted a macro originally, so that I can make decisions like that in the future without breaking everyones code like an angry child with legos
20:47:04
Xach
Shinmera: https://gist.github.com/xach/5e623744fa4777159719619c9eabb4d5 shows some behavior that is confusing to me.
22:42:42
Shinmera
If you want to preserve the package that is used during compilation you need to, well, capture it.
22:45:55
pjb
Shinmera: this doesn't work: the current package is not necessarily available at load or run-time.
22:46:35
pjb
Shinmera: better use something like (load-time-value (or (find-package "FOO") (error "No package FOO")))
22:47:00
pjb
Shinmera: or if you insist, (load-time-value (or (find-package #.(package-name *package*")) (error "No package FOO")))
22:47:10
Shinmera
pjb: I assume this is placed in a file with (in-package ..) at the top. In that case it's just fine.
22:54:36
pjb
Well, what bothers me most, is that you have there a literal package that needs to be serialized in the fasl file, while in another fasl file, there's a defpackage for that will be creating a new package with the same name (assumedly before loading the fasl with the serialized package).
22:56:21
Shinmera
pjb: http://www.lispworks.com/documentation/HyperSpec/Body/03_bdbb.htm "Two packages S and C are similar if their names are similar.
22:56:36
Shinmera
Note that although a package object is an externalizable object, the programmer is responsible for ensuring that the corresponding package is already in existence when code referencing it as a literal object is loaded. The loader finds the corresponding package object as if by calling find-package with that name as an argument. An error is signaled by the loader if no package exists at load time.
22:56:56
pjb
Shinmera: ok. Also, it seems that implementations implement that by using find-package at load time.
22:58:13
pjb
Notice that those are special rules. In general be warry of using #. with complex objects. It doesn't always work.
23:02:10
Shinmera
oleo: This is what I explained to you already. The run-time package is not the same as the compilation package. You need to capture the package that is used during compilation and bind it at run-time around READ.
23:04:28
pjb
Well the common idiom is to bind *package* at run-time. Not necessarily the same as the source package. Usually you prepare a run-time package…
23:28:49
aeth
borei: single-float 4x4 naive (from the definition, but without a loop) matrix multiplication, with the matrix as a flat 16-length specialized array
23:30:00
aeth
Afaik, smarter algorithms only are effective when you go to sizes in the hundreds or thousands.
23:30:43
aeth
borei: The actual implementation is not pretty, but I can cover it up with a macro when I settle on the final implementation. https://gitlab.com/zombie-raptor/zombie-raptor/blob/324c45a11a1ead12c368e1fb8aee1216f2720555/math/matrix.lisp#L160-185
23:31:35
aeth
I had to make matref a macro rather than an inline function because there simply is so much of it. Loading the matrices into variables and then working on the variables seems to be slower for the 16-length version, though.
23:31:57
aeth
Loading *some* into variables and accessing the array for some seems to be faster, but that... that would get complicated quickly.
23:33:53
aeth
Even with a 2D array (I played around with various implementations, just not uploaded) a matref (in that case, just (1- i) (1- j)) is essentially necessary because it's just too easy to make off-by-one mistakes unless I use a 1-based matref
23:37:45
aeth
Oh, and in case it's unclear, all of my matrix operations modify a destination matrix, either a native-CL one or a C one that can be fed into CFFI for graphics.
23:39:19
aeth
If I want to use it in the REPL, I can just feed the result into a matrix created by (zero-matrix)
23:48:16
borei
i just did timing for nested loops for 4x4 - best i was getting ~2700 cycles, in most cases it's in 4-5k range
0:40:09
drmeister
ACTION is a daily 5+year slime/emacs user who switched 5 years ago after 20 years as a vi/vim user.
0:40:56
drmeister
I'm giving a talk next week to non-lisp people many of whom use vi and I want to check out slimv
2:08:01
shrdlu68
How widely used are non-free implementations, and what is attractive about them over free implementations?
2:13:21
aeth
shrdlu68: Probably hard to tell because this is Freenode, and that gives us a skewed view.
2:15:02
aeth
shrdlu68: The advantages of proprietary CLs are, afaik: (0) IDEs that aren't emacs, (1) graphics toolkits, (2) standalone binaries with tree shaking.
2:17:14
aeth
shrdlu68: The advantages of proprietary CLs are, afaik: (0) IDEs that aren't emacs, (1) graphics toolkits, (2) standalone binaries with tree shaking.
2:18:36
aeth
Not too surprising that the idea came from Lisp. You're probably not going to use the majority of the large language in any application.
2:19:57
Pixel_Outlaw
Seems like with functions being first class data types that would be difficult since they could be bound and executed at runtime.
2:20:54
Pixel_Outlaw
You may have a slot in a CLOS instance a user is allowed to assign but may not.
2:21:12
shrdlu68
Tree-shaking sounds like a rather attractive feature. Is is particularly difficult to implement?
2:24:17
aeth
Oh, I forgot. There are some other value-added things that a proprietary CL might have. They might embed a database or a Prolog, etc.
2:26:28
sjl
drmeister: a few of us have switched to VLIME from SLIMV, so that's something to check out as well
2:29:16
aeth
shrdlu68: If no one can answer your question, you could try asking in the implementations' IRC channels about what it would take in a particular implementation.
3:17:47
pierpa
shrdlu68: commercial implementations all have free limited versions to try, so just try them
3:36:26
rme
Somehow, the LispWorks people are able to make a living selling a CL implementation. I think that's amazing (and admirable).
3:36:39
pjb
shrdlu68: tree shaking is not more complicated than the garbage collector. eg. ccl has a :purge option to save lisp image. The only difference is that with tree shaking you will start from a smaller root set, assuming that you won't have to further reference any interned symbol.
3:39:20
rme
And Clozure's business has never been selling a CL implementation (namely Clozure CL) as a product.
3:40:00
pjb
Indded, they cheated with consulting. (But Franz does consulting too AFAIK, and probably Lispworks also).
3:49:57
aeth
pjb: There are a surprising number of commerical Lisps. At least Allegro, LispWorks, Scieneer, and mocl. Genera might also still count, since I think it's still being sold.
3:59:35
rme
If you can get $3000/yr/copy for 200 or 300 copies, you'd be doing OK. You won't be earning big money, but that would be enough for a sustainable little business.
4:01:26
pjb
rme: that said if the business sells free-software implementation, it remains in the charter AFAIK.
4:43:52
pjb
JuanDaugherty: remove taxes, overhead, shareholders' share, I'm not even sure you can pay 2 engineers with that…
4:44:38
pjb
And contractors are not cheaper than employeers. The advantage of contractor is that you don't have to pay them when you don't have work for them.
4:49:34
JuanDaugherty
which is why the major firms virtually all supplement their wage slaves with contractors
4:53:24
loke
pjb: WHat kind of buffer do you have? In the sense that if you stopped getting contracts tomorrow, how long would you last before having to look for wage-slavery?
4:53:56
JuanDaugherty
however to directly deal with free labor would be like tolerating the striking of a white man, so they virtually all deal with front firms that actually hire the contractors
4:54:06
pjb
loke: of course it's variable. From a few months to almost one year, depending on the previous project…
4:54:44
pjb
wxie: well, it was so long ago, I don't know if it would still be meaningful. Basically, at that time, there were so few programmers, that just announcing you were one, you'd get calls.
4:55:17
loke
That means I have enough buffer in cash (about a year or two on current burn-rate) to actually go ahead and do what you're doing.
4:55:40
JuanDaugherty
and even in 2018 said firms, which uniformly add nothing to the labor they resell, in general, operate at unknown markups
4:55:44
pjb
JuanDaugherty: And foremost, to deal with the details of the hiring process. Only programmers can hire programmers; customers rarely are in the programming business.
4:56:13
pjb
wxie: it happens some times. But it's not worth it, since being employed is usually being paid less…
4:57:09
pjb
JuanDaugherty: it's not the worst: you may be at the end of a long chain of subcontractors…
4:57:23
JuanDaugherty
the firms that hire contract labor are almost always either as their main line of biz or defacto in IT
4:58:25
JuanDaugherty
uh, that may be one thing that's changed somewhat, more parties than 3, 4 at most
4:58:26
pjb
For example, a bank wouldn't care hiring programmers. Instead they contract with a company to furnish the programmers. This company may be lazy and hire head hunters to find them, and so on.
4:58:54
loke
pjb: Actually, many banks have their own programmers. Some banks have more than others.
4:59:19
loke
pjb: Certain banks have more well-staffed development teams than major banking software makers.
4:59:23
pjb
Also for the bank, if they need to change the work load, or need to replace a programmer, it's simplier for them to delegate the HR problems to the contracted company.
5:00:12
pjb
Of course, a company that realize that software is the core of their know-how would want to have the development done in-house…
5:02:06
pjb
wxie: in general, you can use MIT or BSD -like license, but if you want to contribute back, you have to go thru their legal departments, and you never hear back from them.
5:05:35
pjb
wxie: if you remain the owner of the software, then you can license it as you wish. Very few (ie. none) customers are aware enough of the licensing question to care.
5:07:02
pjb
wxie: basically, if you sell a proprietary license to your software, you can sell cheap a non-exclusive license, but then you can sell copies to their competition!
5:10:24
wxie
pjb: I do not have any software to sell, and would never sell any under non-free license.
5:12:00
wxie
pjb: Maybe we can think over a time-bounded free license: if the customer owns the software, she should agree that you can publish it under free license after a certain time.
5:28:34
Xach
Shinmera: Thanks. I didn't realize that's how it works. The example in the readme didn't drive it home for me.
5:28:56
borei
read some perfomance reports in regards to matrix multiplication and CPU performance. found that what i got now is 1% of possible performance
5:29:56
beach
borei: I think you are working in a highly competitive domain. A lot of smart people with a lot of money have worked on this problem for a very long time.
5:32:05
beach
borei: I don't think such performance is reachable using only the standardized features of any language, Common Lisp included.
5:34:53
beach
Like I said, you have chosen a very competitive domain. You have a lot of reading to do if you want to compete.
5:43:13
pierpa
btw, wikipedia says the best known algorithm for matrix multiplication is O(n^2.3728639)
5:44:38
pjb
It's worth implementing it, it looks like. (/ (expt 1000 2.3728639) (expt 1000 3)) #| --> 0.013139899 |#
5:45:54
rme
IIRC, the magnitude of the constant factor is so high for the O(n^2.4) algorithm that it is totally impractical.
5:46:38
pjb
Of course, if you're doing 4x4 it's probably not worth it. But for 1000 or 1000000, I'd bet any overhead is worth it.
5:49:19
rme
Strassen's algorithm, which is O(n^2.8) IIRC, is actually worth it for relatively small matrices. But I'm remembering this from quite a while ago.
5:50:26
pierpa
I heard Prof Romani (whose algorithm was for a period of time, in the '80s the best known) talk about this topic.
5:51:16
pierpa
his opinion was that algorithms asyntotically faster than Strassen are not usable in practice
5:52:05
pjb
Well, "However, the constant coefficient hidden by the Big O notation is so large that these algorithms are only worthwhile for matrices that are too large to handle on present-day computers." so perhaps we'll have to wait a little ;-)
7:08:26
Shinmera
Xach: Yeah, I realise that should be clarified. I can also see a point to your attempted use-case, but I don't know if it would lead to more or less confusion in the long run.