freenode/lisp - IRC Chatlog
Search
15:26:43
knegg
im reading a book on neural networks and LISP came up and im reading about homoiconicity. i have some basic programming knowledge and am trying to figure out what the specialty of that homoiconicity is.
15:34:13
beach
knegg: There are no "commands" in Common Lisp. EVAL is a function that that takes data that represents code and executes that data as if it were a program.
15:35:58
knegg
hmm.. data that represents code. if something is code then its code unless i would mark it as text in vba (sorry - i said basic :])
15:37:08
puchacz
knegg, you may want to see the presentation "clojure for java programmers", where the clojure author explains what "code is data" means in lisp world
15:37:29
beach
knegg: In Common Lisp, the READ function turns a sequence of characters into a data structure. Whether that data structure represents code or not depends on what other program is processing it.
15:38:14
beach
knegg: For example, if it is further processed by the compiler, then the compiler assumes that the data structure represents code.
15:47:51
beach
knegg: Most languages do not expose the representation of code, other than as a sequence of characters.
15:48:29
beach
knegg: Common Lisp has a defined way of turning that sequence of characters into code represented as nested linked lists, symbols, numbers, etc.
15:49:15
beach
knegg: Then, everything else in the language is defined in terms of those nested lists.
15:50:06
knegg
the big point must be that the following java code (in that video) for that simple example is about 3 pages long.
15:52:38
knegg
i think i need to get what that code is doing. he defines a function that sets variable b (which obviously is not a variable because it is lisp/clojure)to 15. then by that function (eval a) he returns that "variable" and for the program this is both the variable and the value 15 ? am i getting it right so far?
15:54:32
beach
knegg: I didn't watch the video. But let's do the analogous thing in Common Lisp, to be on topic. If I type (defparameter a '(defparameter b 15)) for instance...
15:54:46
Bike
that sets the value of the variable A to be a list of three elements SETF, B, 15. then (eval a) means the value of A, that is, that list, is passed to the eval function, which treats the list as code and performs what it says to do, namely (setf b 15), which sets the value of the variable B to be 15
15:57:13
Bike
also, in his notation here, the return values are indicated in the comments. (eval a) will return 15, not the symbol B
16:03:17
Bike
well, we might more specifically say A is a symbol that names a variable, but we often conflate the name with the variable
16:06:17
jackdaniel
setf is an operator which sets places (place is more general than a variable behind a symbol
16:10:15
beach
knegg: You can see it as if in C you had a function eval that let you do eval("b = 15"); the result of which would assign 15 to the variable b.
16:10:31
knegg
so 1st line defines what happens when a is called/executed. then 2nd line does that and the variable b is set to value 15. then 2nd line is just "a" which i take the program to run the thing and assign the value 15 to variable b.
16:11:20
Bike
your framing in terms of "called/executed" is wrong. a variable binding is just a mapping from variables to values.
16:12:08
Bike
the first line sets a value of a. the second line just returns the value of a without doing anything.
16:12:47
Bike
between lines two and three, B has no defined value, unless it was defined earlier i guess.
16:16:09
knegg
the ;; and => is indicating what? what i would see when i do somehting line "print a" "print b"?
16:20:23
knegg
ok, 2nd line gives me the value of a which is the list i assigned it and 3d line (eval a)gives me not the list like when i let the value of a return but it gives me the 2nd element of the list.
16:22:00
Bike
that's because eval would evaluate the list SETF, B, 15, and the assignment returns the value (15)
16:24:40
knegg
(oh.. why does it put 15 in comment text then?)so (eval a)does nothing by itself but b in the next line will return the value for b which is 15? like i would define setf b 15 c 28 and then go (eval a)c it would return 28?
16:27:34
knegg
you are doing your best mate! but i think i need to actually do a basic lisp tutorial to understand it.
16:36:17
akoana
knegg: I'm too learning Common Lisp, entering the example code into a REPL session is quite instructive... play with the real thing :)
16:40:42
knegg
whats repl? im watching a tutorial on the syntax now. maybe that helps for that simple example already
16:42:26
akoana
knegg: when you start a common lisp you it will wait until you enter something and read it
16:45:56
knegg
im glad it does. on the recent vba version the alt+ctrl+break doesnt help anymore. had a hard time exiting my latest endless loop :D
16:50:42
akoana
knegg: portacle (https://portacle.github.io/) has everything you need, it runs on Windows, OS X, and Linux.
16:53:32
knegg
ok cool. ill try to understand that concept with minimal effort to be frank because i wanna continue with that book to continue with another book... looking into machine learning took me several days already. its super interesting and i understood the basic stuff but i did not programm any neural networks there either :D
16:59:22
knegg
"to be fairly easy to use so that even intermediate Common Lisp programmers" thx man. but.. im a total noob :D
17:07:27
knegg
lol... the video tutorial on lisp ends at min 6:31 with nothing like eval. only having shown "strings", 'symbols t, nil and how calculations are done :D
17:08:39
akoana
knegg: hey, using _death's suggestion (cl-mep) you'll have fun and will advance by exploring the examples
17:09:16
akoana
knegg: I'd also recommend Little Bits of Lisp https://www.youtube.com/watch?v=m0TsdytmGhc
20:49:48
puchacz
phoe: most ML is done by wrapping C++ or C libraries in Python, basically - how does it compare, do you know?
20:50:24
puchacz
with Matlab being astonishingly slow, and Python C/C++ fast, do you know where does cl-mlep sit?
21:13:27
puchacz
jfb4: I am on a course in a bank, there was just one class as of now, with neural network recognising handwriting digits, honestly I did not check the full curriculum.
21:13:53
puchacz
but I would like to know if a library can "scale" to be used out of the course as well
21:44:55
no-defun-allowed
puchacz: Depends on your compiler, but you should expect fairly close to C.
22:36:29
_death
I thought cl-online-learning would be cool for actual use, though I've not yet had the chance
0:04:40
no-defun-allowed
As in, (find-class '(your . cons)) will give you that class, or that the class-name of that class is your cons?
0:05:25
mfiano
The latter. Don't ask why. I think both of our heads would explode if I tried to explain it. It just seems like the best abstraction for a hard problem I've been trying to solve.
0:05:37
no-defun-allowed
I think you can do (make-instance 'standard-class :name '(your . cons)) to make a class that has a cons for a name, but I don't know if it's portable.
0:05:56
mfiano
I would like to (make-instance '(pkg1:foo pkg2:bar) ..) but if it's not possible I'll continue my search
0:11:57
pjb
mfiano: make-instance is a generic function. If you can map your list onto a symbol, then you can do it.