freenode/#lisp - IRC Chatlog
Search
4:41:46
phoe
theemacsshibe[m]: (cond ((acquire-lock lock :wait-p nil) (release-lock lock) t) (t nil))
4:42:33
theemacsshibe[m]
didn't think about using acquire like that, thought there'd be an acquired-lock-p or something
4:43:48
phoe
The state of the lock can change betweeen evaluating the condition and one of (FOO) (BAR)
6:14:27
flip214
phoe: also, the state of the lock might change while your COND is returning T ... or at any later point as well, so IMO a LOCK-ACQUIRED-P would be okay.
6:14:53
flip214
after all, your COND can just be put in a (DEFUN LOCK-ACQUIRED-P (lock) ... ), right?
7:55:17
minion
dadabidet: look at pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
7:55:40
jackdaniel
fact that something has a compiler doesn't mean you can't use it interactively with REPL
7:56:06
jackdaniel
the distinction is that compiler takes your code, performs some optimizations and outputs target bytecode (be it binary or some bytecode)
8:03:25
jackdaniel
kuribas: I don't know basic, so I can't tell. but you may check out tagbody/go syntax and decide yourself
8:04:10
jackdaniel
kuribas: tagbody/go is usually used in macros which implement better abstraction on top of this
8:07:04
jackdaniel
dadabidet: in lisp form is either an atom or a list. some atom examples: `3 "string" symbol nil #(1 2 3) T', some list examples: (1 2 3) (foo 1 2) nil
8:08:04
jackdaniel
for the evaluation rule I'd suggest looking into some basic tutorial or a book (SICP is a good one, targetting scheme though)
8:08:34
jackdaniel
but in code ` means backquote, which has some special characteristics, while ' means just quote
8:08:56
jackdaniel
that's why reading short tutorial is a good idea, you don't expect to learn basic from stranger on irc, do you? :-)
8:09:51
jackdaniel
because random strangers usually are busy with their own endavours, that's why they end up with writing tutorials eventually
8:10:29
jackdaniel
chapter or two from PCL should take you around an hour or two. after doing it you should have basics grasped
8:10:52
jackdaniel
book "ANSI Common Lisp" by Paul Graham is another book which introduces you to the basics in first chapter
8:12:22
jackdaniel
this looks not-so-bad, though the author got some indentation wrong: https://maxtimkovich.com/lisp_tutorial
8:17:17
jackdaniel
bear in mind that I'd still recommend reading first chapter or two of the mentioned books instead of going through that
8:19:14
shrdlu68
dadabidet: You could check out examples on rosettacode and compare c/c++ to CL examples. But you'll still have to look up explanations for things you don't understand.
8:33:58
beach
dadabidet: Did you have any reasons to believe that Common Lisp could not be used for high-performance programs?
8:35:55
dadabidet
well it was not about lisp, weirdly, but about functional programming... https://en.wikipedia.org/wiki/Functional_programming#Efficiency_issues
8:38:38
beach
kuribas: Yes, because if it were, I could not use the excellent object-oriented capabilities that I have gotten so used to.
8:39:05
dadabidet
https://en.wikipedia.org/wiki/Lisp_(programming_language) wikipedia says it's functional
8:39:35
beach
kuribas: I am using "functional programming language" in the sense that mutation is not allowed.
8:40:03
dadabidet
although language classification are not very precise. and the paragraph about functional not being fast sounds weird
8:40:41
dadabidet
kuribas, not in pure functional, which is used in multithreaded? or high performance?
8:41:27
kuribas
dadabidet: it is controlled, and pure functions are separated from side-effecting procedures.
8:43:48
shrdlu68
By wikipedia's definition, almost all languages are support the "functional" style.
8:44:19
beach
kuribas: That makes absolutely no sense. If you mutate something, then by definition it is not unmodified.
8:47:03
dadabidet
My brain has trouble with lisp because since the brace is the mostly used separator, my brain has to build a hierarchy which is visually harder to see
8:47:44
kuribas
dadabidet: the idea is that you can look at a function signatures, and know if it does side effects or not.
8:48:23
shrdlu68
dadabidet: You're not alone in that, but you'll get used to it, if you give it a try. Not "used to it" in the "put up with it" sense but "get it".
8:49:40
shrdlu68
dadabidet: There's a symmetry and uniformity to lisp syntax that makes it one of the language's most endearing features for me.
8:50:21
beach
kuribas: We write it "Lisp" these days. If you write "LISP", people will think of 1960s dialects.
8:52:48
jackdaniel
kuribas: copying argument first and mutating it gives you referential transparency, not a "pure" function
8:54:44
shrdlu68
dadabidet: Compare: https://gist.github.com/shrdlu68/f13ffcfb25f34e4aea960854c7537ada
8:56:55
kuribas
jackdaniel: the type system ensures that the "mutated" array cannot escape the function.
8:58:30
shrdlu68
dadabidet: It gets especially ugly when the the or statements don't fit on the same line in C-style syntax.
9:01:31
shrdlu68
dadabidet: Certainly, but observe what happens: https://gist.github.com/shrdlu68/22bcc02e164199f90febe70b5eadebc5
9:02:53
jackdaniel
I've checked some sources. given wikipedia definition you are right, given haskell, ANSI CL (book), hackernoon and fpcomplete.com description you are not
9:04:06
jackdaniel
(that is, wikipedia seems to make both therm "pure function" and "referentially transparent function" semantically the same, while other sources claim, that "pure function" doesn't have side effects *at all* in its definition in opposition to referentially transparent function, which may mutate some copied variables)
9:05:56
jackdaniel
there is also interesting discussion in SICP about side effects in languages which are compiled and executed on a computer - under the hood (but really under the hood) function execution takes time, makes processor warmer etc, so you can't really claim side-effect fee
9:06:15
shrdlu68
dadabidet: But because most people are not introduced to s-expressions until they have throroughly adapted to parsing C-style code, they find it jarring.
9:07:10
jackdaniel
dadabidet: nothing really, but having (at least) referentially transparent function gives you some interesting qualities
9:07:13
shrdlu68
Hence "Lisp has all the visual appeal of oatmeal with fingernail clippings mixed in".
9:07:20
xificurC
mapcar may be a bad example because it is a HOF so the function it takes can do side effects
9:07:51
jackdaniel
and that would be transparrent to the programmer (except the fact, that program may be faster)
9:08:32
jackdaniel
xificurC: yes and no. imagine scenario, when your referentially transparent function copies matrix. you are short on memory (and matrix is really big). you may run out of heap
9:09:23
xificurC
jackdaniel: even haskell doesn't try to pull these qualities into the type system AFAIK
9:10:31
xificurC
purity is a hard concept but usually when a language is talking about purity it does define it
9:11:18
jackdaniel
dadabidet: ECL (embeddable common lisp) allows you to inline C (and use Lisp libraries in your C application)
9:11:35
jackdaniel
also most Common Lisp implementations have FFI (foreign function interface) which allows you using C libraries from Lisp
9:13:08
shrdlu68
dadabidet: Lots of people claim so. "Perl 6 is Lisp with a decent syntax, and minus a lot of assumptions about how lists should be represented :)" -- here is a man who would be okay with lisp but for the syntax.
9:13:45
jackdaniel
many concepts which were pioneered in Lisp got into languages which borrow syntax from C
9:15:54
kuribas
dadabidet: it's not bad, but a sideeffect-free (pure) function, can be understood without requiring knowledge of the surrounding context.
9:17:07
kuribas
dadabidet: in effect, it depends only on the inputs it receives, while with mutation, you depend on the global state as a whole.
9:18:49
dadabidet
but pure function are good since they increase locality, so you reduce the risk of invalidating your cache line
9:32:54
dadabidet
language developed by mozilla, it doesn't have a return statement, so as long as a line doesn't end with ; is it considered as a return, like so {let x = 3; x}, which, to be honest is like a hidden return statement
9:33:37
dadabidet
it solves many problems of the unsafety of C/C++/Java, all of this at compile time
9:35:55
dadabidet
I think that enforcing safety is a good way to achieve performance... but at least in a world where security matters more, it can be somehow relevant to mozilla
9:36:00
flip214
assembler on microcontrollers (anything without a MMU, even) doesn't have NULL pointer exceptions, too - illegal accesses aren't, they just don't return the expected (or, rather, hoped for) data ....
9:44:24
flip214
shrdlu68: to stay CL-on-topic here, just use a custom readtable to convert whitespace to CL calls. should be fast enough.
9:49:31
flip214
kuribas: there is? really? always? and I always thought that the most applicable programming variant depends more on your algorithms and data structures...
10:00:41
flip214
"there is a performance penalty for pure functional programming." isn't always true
10:14:52
dxtr
I'm no compiler expert but I've always assumed that with an imperative compiler you can get away with being pretty naive (Don't have to copy data when it changes, etc)
10:15:34
dxtr
With a functional language you can't be that naive and have to do some acrobatics to make stuff efficient
10:18:43
kuribas
dxtr: a naive imperative compiler is easy. But doing optimizations in the presence of side-effects is hard.
11:09:00
beach
Here is an interesting conundrum. In SICL, I plan to implement a garbage collector with two generations. The younger generation is per-thread and the older generation is global. The collector of the older sets a flag in the application threads when it decides to run the GC. When a thread encounters a safe point, it runs its own young-generation GC and then indicates to the global collector that it has finished. When all threads
11:09:06
beach
But a thread can be stopped arbitrarily long, for instance waiting for I/O or some user gesture, or it can be stopped by a debugger thread. It would be unfortunate if the global collector could not run in such situations. So would it be OK if a stopped thread can still run the GC?
11:10:29
beach
It also means that there must be some restrictions on the places where a thread can be stopped. It has to be a place that allows for the GC to run.
11:11:31
beach
And that restriction seems to exclude stepping instruction by instruction in the debugger.
11:17:05
shka
beach: i don't see why preventing GC from running while stepping would be a practical problem though
11:18:11
beach
shka: Well, there can be other threads running at the same time, and those threads might allocate memory.
11:19:23
LdBeth
beach: how about invoke local GC after waiting and then the main GC just skip the waiting thread