freenode/#lisp - IRC Chatlog
Search
15:32:08
comborico1611
Something wrong with computer. Rebooting. Can't remember password. All i have at the moment is a functional version.
15:33:44
comborico1611
It is a shame how many programming languages have borrowed from Lisp, and don't give it credit.
15:36:23
comborico1611_
This is the functional version -- not my preferred one. I'm nt even sure this one works.
15:36:57
comborico1611_
Still trying to rmember stupid ghitjp password -- just let me have a simple password
15:39:51
comborico1611_
Here is proper seconds program, I believe. https://gist.github.com/COMBORICO
15:43:14
comborico1611_
It should be very easy to write up in Lisp. I'd just like to see it in Lisp for myself, without having to read a few chapters more than I have already.
15:45:39
beach
I usually help people when I think it might be a good investment, i.e. that the person I help will later contribute to the common code base. I don't have that impression in this case.
15:46:15
White_Flame
again, just go do some basic lisp tutorials, and you'll have enough to figure this out on your own. Or, start using the builtin decode time function
15:46:29
comborico1611_
beach, that's fine. I don't claim that I would do that. Just a guy looking to see a sample of this code in this language.
15:46:33
jmercouris
comborico1611_: What are you asking for exactly? if you want to learn lisp, just learn it, if you encounter issues in the path of learning we can help
15:47:08
jmercouris
comborico1611_: don't just ask people to randomly write up functions for your amusement, have some respect for people's time
15:47:15
comborico1611_
jmercouris, again for the fifth or more time. I'm just looking to see a sample code of how this task would be done in CL.
15:48:04
comborico1611_
jmercouris, asking for a simple program to be written by someone affluent in a language doesn't seem disrespectful of someone's time.
15:48:11
White_Flame
Lisp doesn't look like other languages, so whatever introduction you've had before isn't going to help you read Lisp
15:48:29
jmercouris
yes it totally does, because you are ignoring what everyone is telling you, that it is a waste of time
15:48:42
White_Flame
comborico1611: there are already tons of resources to help you learn. You're trying to bypass them for no defensible reason
15:48:43
jackdaniel
this looks very much like you have an assignment from uni (or wherever) and you think that you will "outsmart" people on lisp by asking them to write it for you (with some improbable excuse)
15:49:51
comborico1611_
This is terribly simple code. I just want to see a sample of it, inspect how I feel the language is reflected by the code *before* I commit time to learning a language.
15:50:33
jmercouris
I don't speak for everyone here, but I think I have a good pulse of what many are thinking
15:50:38
White_Flame
"show me written Chinese before I learn the language, and I'll use that to decide whether or not I want to learn it, because there's a lot I can intuit from it"
15:50:56
comborico1611_
jmercouris, you have a reading comprehension problem. I detailed before the reason I preferred this specific example.
15:51:17
jmercouris
I don't have a reading problem, you simply don't know how to program in any langauge, so I don't see how that would help you even if it were true
15:51:20
White_Flame
you've see multiple examples, you've seen multiple tutorials. your question repetition is pointing that somethign else is wrong
15:51:29
comborico1611_
jmercouris says "you are ignoring what everyone is telling you". sounds like you rpresent everyone
15:51:57
comborico1611_
jmercouris, you hurt my feelings. I'm not able to program blah blah blah lanague blah blah. I'm done with you, loser.
15:52:22
jackdaniel
actually he assessed your attitude based on your reactions to what others do (he didn't mention "others" internal motives / feelings)
15:52:37
jmercouris
comborico1611_: I don't think hurting your feelings makes me a loser, but that's not what I'm after, I'm just trying to help, maybe I did the wrong approach, sorry for that
15:53:45
pjb
comborico1611_: the first macro generated a function that looped over the bases list; instead, the new solution expand to the truncate calls like Bike's solution.
15:54:41
White_Flame
and just to be clear, pjb's solutions are advanced. So if you want to see examples of "real" lisp beyond just hardcoded toy examples, there you go
15:55:12
comborico1611_
Bike, thanks for your help! I found your code. Whew. I think he did in less than 3 minutes. Cry babies not wanting to demonstrate some code. Gee wiz.
15:56:08
White_Flame
well, that's one way to admit that you can't read code yet, given the number of links that have been posted. Again, go through tutorials to learn how to read the code if you want specifics
15:59:40
pjb
Notice however, that both the standard decode-universal-time and my macro and functions take and generate the list in the least-significant first order. Since lists can grow unbounded, that let the code know the meaning of the first elements of the list without having to compute its length.
16:01:22
comborico1611_
pjb, it's difficult for me to follow. But I do have a question. I have read that using macros un-needlessly (meaning unless you are forced) is considered a violation of best practices. Do you agree with this?
16:02:32
pjb
comborico1611_: you may find it funny, but both my code and _death are really demonstrating the strong points of lisp.
16:03:38
pjb
comborico1611_: If you wondered why you should learn lisp, you got the perfect answers.
16:04:41
Bike
i was not. don't impugn my motives. i did what i was asked, while saying i didn't think it was a good question.
16:05:01
jackdaniel
Bike: pjb and _death have fun with him (well deserved I suppose despite the fact I don't find such toying funny at all)
16:05:52
Bike
that's why i said the actually this has been the channel for an hour so i'll just come back later
16:05:56
jmercouris
I'm certainly pro-humor, as long as it isn't at the detriment of someone else, and I don't think _death's is evil natured or anything
16:06:08
comborico1611_
Now everyone go get some coffee. I need to study these codes. Thank you all who particpated.
16:06:24
pjb
jackdaniel: _death and my answer demonstrate meta programming, which is the strong point of lisp. My answer demonstrate a macro that generalize the problem statement so you can use it with Aztec or Babylonian number systems; _death demonstrate a general technique (the "inteprreter" pattern as the GoF puts it).
16:07:41
jackdaniel
however if you read into it, it is not obvious who is trolling who. maybe it is a self-driven vicious cycle.
16:08:48
jmercouris
at the end of the day, it doesn't matter who was trolling who, it was an interesting journey, and in some ways pretty informative, I'm actually trying to understand _death's code
16:11:56
jmercouris
_death: so each cond line basically covers a case, first one empty program, second one a number, and then whatever operands are supported, right?
16:13:05
_death
jmercouris: yes.. a better name for the function is EVAL... you may find similar functions in various Lisp books :)
16:13:25
jmercouris
_death: I get the gist of your snippet, I couldn't write something so elegant, but I could make a very clunky version I think
16:14:00
jmercouris
also "elegant" because of course it assumes a lot and isn't really extendable, but it is nice and compact
16:16:35
pjb
jmercouris: the hint is the use of progv, which is specifically designed to implement interpreters :-)
16:18:03
pjb
White_Flame: but codeshare is designed for collaborative editing and development; there's a videochat module.
16:20:56
jmercouris
If two people ssh on to the same machine, and that machine is running emacs daemon, and they both launch an instance to a file, can they both see that file being edited?
16:24:16
jmercouris
I believe sbcl complains when you don't use defgeneric, but in practice, is it bad?
16:24:44
pjb
jmercouris: there are advantages of doing them. On the other hand, it's a bore for accessors.
16:25:04
pjb
The main advantage, is that it allows you to document the generic function; also you can provide a default method.
16:25:15
_death
if you think in terms of protocols then you generally want to write defgenerics anyway
16:25:51
pjb
And since this allows you to explicitely define and document the protocol, you can easily export it from a package. So there's no problem when several different package define methods to the same generic function.
16:25:54
jmercouris
writing a set of defgenerics is effectively defining a protocol for objects of a class
16:27:10
jmercouris
or rather, a possible purpose, I'm not sure I have the whole picture yet, but yeah
16:28:14
pjb
jmercouris: for example, since methods are not attached to classes but to the generic function, it make sense often to just define them with the :method option of defgeneric. Keeping all the methods in the generic function, instead of spreading them all over the project.
16:30:32
beach
These days I even stick a DEFGENERIC in there for slot accessors. If I don't, the default signature has OBJECT as the name of the parameter, but I often want something more specific.
16:32:24
comborico1611_
Thank pjb and _death for your time. When bike gets back, tell him I bless him in the name of Jesus Christ.
16:33:23
White_Flame
comborico1611: besides this weird exchange we've had here, you should probably ask further learning questions in #clnoobs
16:34:17
comborico1611_
I've saved the programs, not to use as a homework assignment, but to meditate on. As I stated earlier, I know Lisp is the most powerful progrmming lanugage.
16:35:50
White_Flame
(that's still like meditating on a foreign language text, instead of meditating on the instructional materials to learn the language)
16:37:05
comborico1611_
And I adore Emacs. My main career is in Web Development and design. I have an interest in programming, but I'm not sure if I'm *that* intested. I only have Saturdays to dedicate to programming, when I do decide to dedicate it to learning programming. So that is why I requested a sample of this particular program. I don't wish to dedicate my free Saturdays to learning just to see a sample code. I thank this channel again fo
16:37:40
comborico1611_
Yes, I know. But it speaks to the verbosity of a given language and other generalities.
16:38:09
White_Flame
lisp can collapse code size compared to other languages, even if it can be larger in small examples
16:38:28
White_Flame
again, you need context to evaluate any of this. You're on the path to cargo cult
16:48:05
pjb
phoe: however in practice, since there's array-total-size-limit (which may be as low as 1024), the practical limit on dimensions is on the order of 10 in the worst case.
16:48:43
pjb
phoe: also, you have to consider call-arguments-limit. You couldn't index an array with that many dimensions (aref takes the array itself as first argument).
16:49:28
pjb
(you could still use array-row-major-aref, but what would be the point of declaring a multidimentionnal array if you can't index it directly).
16:49:54
pjb
So (1- call-arguments-limit) being as low as 49, this could be the lowest maximum array dimension.
16:50:13
scymtym
did anybody see what _death said? also, array-total-size-limit is not relevant in (make-array (make-list 1000 :initial-element 0))
16:53:43
pjb
Yes, that's funny, but Since there's no constraint on array-rank-limit vs. call-arguments-limit, you could have problems :-)
17:40:27
beach
This is how Second Climacs computes the indentation of TAGBODY: http://metamodular.com/tagbody.png compare to what Emacs does.
17:42:46
beach
By now, you should be convinced that the technique that I use is superior to regular expressions for indentation, right?
17:44:40
jmercouris
if I have a method like this (defmethod run-something ((args))) and then I have (defmethod run-something :before ((args))), am I correct in thinking that the method with :before will be invoked before the other?
17:45:47
specbot
Standard Method Combination: http://www.lispworks.com/reference/HyperSpec/Body/07_ffb.htm
17:46:13
jmercouris
I'd prefer something a little lighter than the CLHS, but I'll take a look, thanks
17:48:36
phoe
beach: you could also define some generic "ways" of indenting stuff. You could introduce a thing like &tagbody that is only for defining indentation and otherwise equivalent to &body, but will indent the body forms in a TAGBODY style.
17:50:55
beach
phoe: I considered that and decided against it. It is more complicated than that, because I need to know whether sub-expressions are forms or not. The recursive indentation calculation depends on it.
17:53:44
phoe
Can I define a method for (eql 'cl:do) that will turn its indentation into something tagbodylike?
18:04:11
jmercouris
now that I am starting to get into it, I am seeing what kind of a monumental task this is
18:04:28
jmercouris
especially because I am simultaneously converting the interface to a CLOS object to allow for multiple simultaneous backends
18:04:43
jmercouris
a lot of pain for now, but potentially unbeleivably cool stuff if the implementation actually works
18:05:13
jmercouris
I can imagine a single server running multiple backends on peoples computers, that would be interesting, multiple people with the same "tabs" open, stuff like that
18:20:20
sjl
the stuff said while you were away but your IRC client was connected, which you usually have to "scroll back" to see
18:22:20
whoman
<victim_> jmercouris, you hurt my feelings. I'm not able to program blah blah blah lanague blah blah. I'm done with you, loser.
18:28:02
whoman
i can't find the name of it, but it had special buttons for editing forms and such, a bit like 'touch paredit' , quite experimental. i searched but i cannot remember the name
18:28:03
fourier
APL is the best lang for the phone. Dyalog is working on their version for Android, and J already has a version for Android
18:30:18
whoman
fourier, i think if it were more visual, for eg.: https://joelkuiper.eu/assets/knowledge/lisp-edit.png
18:30:24
jackdaniel
fourier: CL also has repl and editor on android - this doesn't mean it is usable for actual programming
18:30:55
whoman
touch screen is *soooo* beautiful for scrolling and zooming. mouse wheel and keyboard cant compare with that
18:31:12
fourier
jackdaniel: as i said cl is too verbose, apl would really suite well as it is extremely terse
18:32:21
whoman
verbose in text form -- but we could visualize the trees of forms, getting to the verbotic symbol names as necessary
18:34:47
pjb
beach: We would want the expr to align on one column, and the tags to align on their own column.
18:35:16
pjb
beach: I can imagine several kinds of tagbody where writing the tags at the end of the line would be the right thing to do…
18:37:39
pjb
beach: perhaps more seriously, (tagbody tag (expr1) \n longer-tag (expr2) very-long-tag (expr3) final-tag)
18:43:57
beach
It's an impossible requirement. Imagine (tagbody tag1 statment1 <newline> statment2 tag2)
18:44:25
beach
I'll look at it tomorrow. Now I will go spend time with my (admittedly small) family.
18:47:31
Fare
He had a point-free APL optimizing compiler from APL to C++ in ~100 lines of APL (plus C++ headers and runtime).
18:49:05
Lycurgus
the failure was the IBMer contending that he could implement some function, a simple transcendental iirc, quickly, which he could not
18:55:33
fourier
Aaron is former schemer btw. he told on one conference that APL is the only language he was not able to express in scheme
18:57:36
ecraven
I learned some, but haven't really "groked" it well enough to read even simple programs
18:59:33
ecraven
APL finally made me understand that succinctness can be a virtue.. arcfide's compiler on a few pages is just really impressive, and the claim that you can actually keep it all in your head is indeed believable in that context
19:13:16
ecraven
hehe, "...in the simplest manner imaginable" is a quote I wouldn't apply to APL and the co-dfns compiler myself :P
19:21:27
fourier
strangely enough these 2 communities - apl and cl - almost never intersecting. the CL community grows from mature software engineers and science(around AI back in the day), while APL from domain experts and non-programmers
19:26:11
fourier
hm the stance "if its compiles, it most certainly works" sounds appealing, I guess some lispers (like peter siebel iirc) have switched to haskell
19:28:45
stacksmith
I am strangely attracted to this: https://en.wikipedia.org/wiki/APL_(programming_language)#/media/File:APL-keybd2.svg. Do APLers actually remember which key stands for what?
19:28:59
phoe
It worked indeed, except it did not do what I wanted it to do, so I can't say that it "worked".
19:30:33
fourier
stacksmith: yep its not that many of them. also for example in Dyalog APL IDE there is a toolbar with all the symbols so you can just point your mouse and get a hint on it. In GNU APL Emacs's mode there is a popup keyboard with a similar hint when you move mouse over the symbols.
19:31:58
stacksmith
It depends on how you define 'works'. Someone here has written gobs of Lisp code he claims "works", but he doesn't know basic things about Lisp.
19:33:25
pjb
Check the google talk, and read the Formal Analysis of the Remote Agent Before and After Flight.
19:33:46
fourier
pjb: I guess main limitation is the necessity to have a phd in category theory in order to write hello world
19:34:48
pjb
fourier: well, not really, since like in any language you're not forced to use very part of the language to write programs.
19:36:22
pjb
It is possible that eventually haskell become useful. When it will run on formally verified hardware, on which would run formally verified operating systems and drivers, and where all the libraries and network protocols you'd use would have be formally verified. Then perhaps…
19:37:17
pjb
But the main objection I see is that businesses won't finance such development in your life time (they didn't in mine). So don't dream.
19:37:29
fourier
pjb: not really. there is a pandoc which is quite widely used; other apps will come
19:40:03
fourier
there are a few jobs for haskellers; and their activity in reddit for example is higher than in lisp reddit
19:47:59
pjb
Activity in forums is proportional to the difficulties of the language or system. It's not a good sign.
20:55:38
makomo
what would be the best way to create a function from a body of code? i.e. i have a list of forms and want to make a function that will run these forms?
20:56:54
makomo
hm i guess that's doable too, and then i could create a lambda which just calls the one defined by flet/labels
20:58:13
White_Flame
if you have the expressions as list-based data, it will have to end up as EVAL or COMPILE
20:58:26
makomo
from what i can tell, FUNCTION is out of the game because it's a special operator and then i would have to eval it myself (which i suppose flet/labels, etc. do under the hood)
20:59:17
pjb
it depends on the expressions. If they are all function calls, then you can do (mapcar (lambda (x) (apply (first x) (rest x))) '((+ 1 2 3) (* 3 4 5))) #| --> (6 60) |#
20:59:42
pjb
but if you also have macros or special operators, then (compile nil `(lambda () ,@body)) is better.
21:02:40
pjb
Also, it may depend on how you want to handle errors, notably program-errors. With compile if there's a program error, nothing will be called. On the other hand you may do (mapcar (lambda (x) (ignore-errors (funcall (compile nil `(lambda () ,x))))) '((print (+ 1 2 3)) (print (/ 0)) (print 'hi))) #| 6 hi --> (6 nil hi) |#
21:07:51
pjb
makomo: also you have to consider that there are no variables linking your expressions. Perhaps you want some? Why do you have such isolated expressions? Perhaps you want to scan them for free variables and bind them in a surrounding let, so that you can have ((setf foo 42) (+ foo 3)) ?
21:09:19
makomo
pjb: what i'm trying to do is to see how exactly i would implement a small HDL/hardware simulator in lisp. it has already been done in C++ by writing a compiler and a vm, but i'm interested to see how easy it would be in lisp
21:09:37
makomo
so the first thing to do is to come up with some macros to define the hardware components and behavioral processes and such
21:09:54
makomo
and these processes would just contain lisp code which i would stuff into lambdas and store within these component objects
21:11:20
makomo
in this case, since everything is known at compile-time i can just generate lambda expressions myself without using COMPILE
21:12:45
makomo
this code contained within the processes can technically be arbitrary lisp code but should only contain operators which are related to the simulation
21:12:57
White_Flame
you only need to deal with eval/compile if you're loading in code at runtime. Everything else should be doable at macro-time
21:14:37
makomo
if i want to be safe against people putting arbitrary/nasty code into these processes, i would have to first preprocess this code before putting it into a lambda right? i would have to somehow walk the code and allow only simulation-related operators
21:15:45
White_Flame
plus, if you're concerned about reading untrusted code, you need to ensure reader eval macros are not enabled
21:15:49
makomo
well, since it's just arbitrary lisp code, it could contain nasty stuff like "rm -rf /"
21:16:34
makomo
if i had a sandbox, rather than having to check the code myself, this sandbox would only provide simulation-related operators and everything else would be unbound/undefined
21:21:28
makomo
hm i was thinking of running the code in a different package or something, but the code could always just use IN-PACKAGE to switch back i guess?
22:00:37
stacksmith
Does anyone know if vectors of 4-bit unsigned-byte values are handled efficiently by modern implementations?
22:02:30
phoe
because CPUs might not be able to handle them more efficiently than they would be able to handle uint8
22:03:07
Fare
stacksmith, on SBCL (upgraded-array-element-type '(unsigned-byte 4)) says (UNSIGNED-BYTE 4) so you might be in luck.
22:03:19
White_Flame
yes, it's a space efficiency vs code efficiency tradeoff to decide whether to bit-pack <8-bit values
22:03:33
stacksmith
I mean as efficiently as can be expected from an 8-bit vector plus the required shift/mask
22:04:42
stacksmith
Interesting. Does it mean that CCL will store 4-bit values in an 8-bit byte discarding 4 bits?
22:06:34
stacksmith
That is very interesting. Fare: thank you, i will check out cl-launch. And thank you all.
22:09:34
Fare
interesting results for (loop for i from 1 to 128 collect (upgraded-array-element-type `(unsigned-byte ,i)))
22:14:10
stacksmith
why (unsigned-byte 7) for 5,6,7 bits? Does it mean that 7 bits are stored in an 8-bit byte?
22:15:26
pjb
stacksmith: often, for integers, there's only one type tag in the low order bit, so (unsigned-byte 7) is the most efficient way to store small integer (fixnum) values into a byte.
22:16:15
stacksmith
Confused: if 7 means it is probably 8, does 4 mean maybe 8? Does upgraded-array-element-type make any promises about the storage size?
22:17:05
phoe
consult your implementation for the exact details. upgraded-array-element-type can't tell you such implementation details.
22:18:35
stacksmith
OK. As a note, my original question had nothing to do with upgraded-array-element-type...
22:19:20
phoe
stacksmith: I think you can direct your question towards SBCL as it's reasonably fast and has a separate u-a-e-t for uint4
23:58:59
|3b|
unsigned-byte 7,15,31,etc u-a-e-t are probably from the combination of upgrading rules and type lattice, like NIL arrays being strings, since unsigned-byte 7 overlaps signed-byte 8
1:02:08
cranix
i would like to make many declaration of global variables in a loop using defparameter
1:06:06
stylewarning
cranix: (macrolet ((f (n) `(progn ,@(loop for k below n collect `(defparameter ,(intern (format nil "r~D" k)) nil)))) (f 32))
1:09:41
learning
been coding a project in python. it's crazy how differently i think about programming after doing only lisp for a long time.
1:09:42
cranix
this macro calls function that uses intern with format in similar fasion to what You wrote
1:13:01
learning
like i used to think about objects like some sort of abstract idea. now they just look like variables that have their own namespace that you can add variables on to. to be more concrete, i had a problem that required that i "override" (not sure what it's called in python when you define a function that's already been defined). the example solution created a new class in order to override. i wanted to do it in a more st
1:13:02
learning
raight forward way. so i looked up how to just redefine the function. it's actually a really bad way to do it because of a memory issue, but it was just about doing it for the learning experience. i would have never done that before lisp.
1:15:16
learning
instead of just seeing the solution to my problem and not understanding how it works, i not only understand how the solution works but i actually have this driving curiosity to figure out how to code it in a different way
1:16:14
learning
of course i learned recursion from doing lisp and that's prolly the biggest game changer
1:16:54
learning
and getting away from "solve everything by making more types" i think helped me a lot
1:20:43
learning
i laughed when i learned that python doesn't have multiline anonymous functions. so you have to name functions even if they're only going to be called once. that's something i wouldn't even have thought about before. anonymous functions have become my bread and butter.
1:22:06
learning
you can see the difference in mentalities just from the design of the programming languages. like clearly the person who invented python wasn't using lambdas when he created the language.
1:25:02
learning
when i started learning lisp it was definitely on the promises that "it makes you a better programmer even if you never use lisp again" and i'm glad that i can come back to this irc channel and say that i'm now one of those people who got better from learning lisp
1:25:17
GreaseMonkey
if `from __future__ import braces` is anything to go by i think it would be really, really hard to actually get multiline anonymous functions working
1:27:06
GreaseMonkey
it'd have to be a "python 4" where guido somehow reneges and adds braces... which is a shame because python's possibly the most popular programming language that has the machinery required for you to provide a macro transformer (AST parser and compiler + lets you hijack the import machinery)
1:30:43
learning
i mean i dont think it's important to have unnamed functions. it's more about having the mentality to write those functions in the first place. having to name something isn't that big of a deal to me.
2:58:31
stacksmith
learning: just in case you are for real - it is extremely important to have unnamed functions. Otherwise it requires a human to name functions. Lambdas can be generated programmatically. It would be a tragedy if you had to name them - pollution of the package, avoiding duplication, not to mention - why name things that need no name?
3:05:40
whoman
naming stuff is probably the main problem in all of linguistics, speech, communication, programming ...
3:15:01
whoman
dmh, ugh! and my scrollwheel is broken !! so many many many sites these days, have dynamic content, where the scroll nub jumps around and changes size. its a terrible situation
3:15:26
whoman
although to be fair, keyboard or mouse is NO MATCH for touch screen for scroll and zoom
3:16:25
mfiano
I mean how would you implement the ONCE-ONLY macro otherwise, or most correct macros that don't unintentionally capture?
3:18:13
whoman
mfiano, i know =( special cases. is there a clean way to provide prefix on gensym? instead of say (gensym (concat ...)) ?
3:19:30
learning
gensym is fine, it's just you need something on top of it so that you don't have to do it by hand
3:25:23
learning
it's not some complicated thing right. gensym's are just used to avoid two things being named the same thing, yeah?
3:29:01
learning
i wonder how bad it would be to just define a function that creates multiline anonymous functions from a string lol