freenode/#lisp - IRC Chatlog
Search
3:24:13
mfiano
stylewarning: Did you have a video you did a few years ago about lisp math? Maybe I am confusing you with someone else
3:25:16
mfiano
Oh I just started watching excursions :) I didn't know that was yours, so must be the other one then...where is that?
3:26:20
jmercouris
I just dont understand why I'm getting "The function (SETF NEXT::BUFFER-NAME) is undefined."
3:27:00
jmercouris
especially when a (print buffer-name buffer) statement in that exact spot also works
3:31:30
jmercouris
how can it be that (print (buffer-name buffer)) ;; works (setf (buffer-name new-buffer) "new-name") ;; breaks
3:31:32
stylewarning
jmercouris: I don't have any ideas. It looks like it should work very straightforwardly. Does #'(setf buffer-name) in the REPL give you anything
3:40:30
jmercouris
I'm thinking about starting a screen cast so you can just easily see what's on my screen
3:45:21
stylewarning
jmercouris: can you start with a fresh REPL and just paste everything from start to finish?
3:52:10
jmercouris
I load the file using two things, an asdf, and then I push to the central registry
3:52:41
jmercouris
which loads this definition: https://github.com/nEXT-Browser/nEXT/blob/master/next/next.asd
3:56:30
stylewarning
If it errors, then it's probably a macro. You can be extra sure by checking the SETF expansion, which I don't recall how to do off the top of my head.
3:57:37
stylewarning
Anyway, it seems ECL uses SETF expansions for DEFSTRUCT accessors, not functions named (SETF BUFFER-*)
4:03:20
jmercouris
anyways, after this whole debacle, I'm more convinced that version 0.02 must use clos instead of structs :D
4:57:39
stylewarning
the real question to ask is "what is the difference between CLOS classes and structures?"
4:58:37
stylewarning
The shortest and easiest answer id give is that CLOS classes are much more dynamic and flexible than structures, the latter of which are pretty bare-bones in terms of representing composite data
5:01:35
stylewarning
One might use structures instead of classes if: 1. The data are relatively simple and doesn't need to be extended, 2. The data need to be accessed and stored most efficiently, 3. The data doesn't need to be accessed with any sort of generic function/protocol
5:01:57
stylewarning
I typically like structures for functional programming and classes for object oriented programming.
5:08:34
beach
Technically, there is no such thing as a "CLOS class". All classes are CLOS classes and every Common Lisp object is an instance of some class.
5:10:01
beach
What people sometimes refer to as a "CLOS class" should be referred to as a "standard class".
5:13:38
stylewarning
iqubic: I would take beach's comment positively, like you have something grand waiting for discovery :)
5:16:02
stylewarning
Macro enlightenment took me a few years, to understand what their purpose /really/ is.
5:17:32
stylewarning
I recommend this too: Object-Oriented Programming in COMMON LISP: A Programmer's Guide to CLOS https://www.amazon.com/dp/0201175894/ref=cm_sw_r_cp_api_jRmTzbVTFNSJG
5:27:05
godratio
no need to worrry about types for simple tings like this. which i like but lisp this is also not that bad just have to learn the lisp rules
5:27:43
beach
godratio: Common Lisp uses what I call "uniform reference semantics" which means that, semantically, every object is manipulated through a reference (or pointer) to it.
5:29:13
beach
godratio: NIL in Common Lisp can is used for three things: It can mean the Boolean value false, it can mean the empty list, and it can be a symbol.
5:32:56
jmercouris
then why does the page here: https://github.com/diogoalexandrefranco/cl-strings tell one to do use-package?
5:36:14
jmercouris
I guess too many opportunities for collision of just importing all of the symbols from a package, right?
5:38:21
jmercouris
godratio: I believe you have to specify what you are returning from if you use return-from
5:40:12
godratio
hmm yes but the documentation says default is nil and that if your are in a defun block the first argument of the block name
5:40:48
aeth
godratio: If you're just trying to return something from a defun, you don't need return. It will return the last line's final result.
5:41:01
beach
godratio: You typically don't need RETURN in Common Lisp. The value of the last form is returned by a function.
5:43:40
aeth
CL has a real type system, rather than a type system where everything's ruined by the presence of null like far too many languages.
5:43:42
godratio
well i looping through a list and passing in the current element of the list and then checking if its alpha numberic so anything can get passed in so ilike the idea to check if its char type. and if not return nil
5:44:26
godratio
aeth: Sounds good I have not elipsed my mentaltity to grasp the signifgance of that yet
5:44:30
jmercouris
I still don't understand, how do I use a system i've installed via quicklisp, how can I know what the package is named?
5:51:27
godratio
beach: Thanks yes I could get rid of that return now and just give back true or false in that IsWhiteSpace function now
5:53:38
godratio
not too shabby in this case compared to c and it does actually check if its a really char which means you can pass anything to it and will return false correctly compared to the equilavent c function which wouldnt know about the type
5:54:33
godratio
ok ok i hear you i will adjust i am very pragmatica person. I want to use CamelCase for function names and this_notation for data types
5:56:47
aeth
hyphens don't work in most langauges because lazy programmers want to do "1+1" instead of "1 + 1" or "(+ 1 1)" or "1 1 +"
5:57:34
aeth
Most languages can't tell if foo-bar is foo - bar or the symbol foo-bar. It's not ambiguous in Lisp
5:57:53
godratio
yes I like the polis notation style and its easier to as I have noticed it seems easir to apply say some functionality across a range of operands much simpler in lisp than in c like languages
6:03:23
Kovalski
So far the story: the church of emacs is seducing me with promises of salvation, but I must press on. Is there a way, dear lispers, that I may continue with VIM and still be happy?
6:05:08
jmercouris
Kovalski: just use emacs instead, what's the advantage of vim when you can use all vi keybindings?
6:08:07
stylewarning
Lisp shouldn't be edited as "just plaintext". And it happens that Emacs/Slime/paredit have the most use and support
6:10:45
godratio
one thing about slime debugging is its not obvious hwo to go about debugging your code
6:13:43
stylewarning
I hope someone will step up to the plate and make a high quality open source Lisp IDE someday.
6:14:24
stylewarning
Emacs is good but it's daunting and only suitable for those who have a lot of time to dedicate
6:15:11
jmercouris
if Kovalski, who claims to already know vim, just installs evil or some other compatibility layer, what more do they have to really learn? to setup an init file?
6:15:40
aeth
Well, yeah, that's one way to do it. Come from vim that has an even larger learning curve.
6:24:22
godratio
Really just spend two hard days learning how to setup emacs the way you like it and than over a few weeks spend tweeking it a lil here and there i sugges you git yoru config file if you use multiple machines
6:25:12
godratio
other than that what more could you ask for emacs is a programmable text editor and if your learning lisp than for gods sake its damn great for learning lisp and having a programmable text editor at your finger tips
6:25:36
godratio
true ist start off a lil hard but give your self a few weeks to adjust after you set it up and boom your done and rest of your life is just like so easy
6:27:04
godratio
here is mine if you want to have an interseting starting place its a big one file mess cuz i just cobbled stuff together but have helm projectile and some good themes runs on my mac and windows machine at home and at work so should be good
6:28:23
godratio
for most modes anyways i need to setup org mode for that moviement style i like vim keys set up on the JKLI i just dont like modal style as always have Control key set up where CAPSLOCK is so no pinky issue
6:31:16
godratio
fitting good one thing I have learned so far is that if your coming from C like langauges PROGN is your friend haha
6:34:59
godratio
I started with http://www.gigamonkeys.com/book/ this after a few chapters got dry and started just tyring things on my own and now reffering to this
6:35:14
jmercouris
beach: I would say progn is more similar to () in other languages because all the inner forms get eval'd and returned as "one value"
6:35:43
godratio
and this is another good run down i like https://learnxinyminutes.com/docs/common-lisp/
6:44:38
AxelAlex
Hey, does anyone have a suggestion for a good library or framework for writing web servers?
6:51:53
godratio
hmm so how can you get the first char of a list as a sequence. Concatenate take only sequences of characters
6:54:58
Shinmera
jmercouris: Shirakumo is my group, but I effectively wrote it, so you weren't far off :)
8:00:55
loke
It's called Autolisp, but it's different enought that you won't be able to get any help here.
8:02:09
jackdaniel
and http://web.ist.utl.pt/antonio.menezes.leitao/Rosetta/tutorials/introduction.html
8:02:12
loke
Filystyn: But I'm sure there are user communities out there. It's just that I've never seen them (but then again, I haven't looked)
8:02:38
jackdaniel
Filystyn: these are scheme-based languages, so you may find help on #scheme for some language-specific questions
8:05:59
jackdaniel
Filystyn: for 3d modeling you may also see http://www.gendl.org/ which is written in Common Lisp
12:47:11
godratio
still not for sure how lisp llikes their enums but this code is not so lispy but its how a c person writs lisp but still works and getting the hang of it.
12:48:51
godratio
regarding the (defvar token_cfg_doubledash ‘doubledash) yeah i will chagne that first t
12:49:53
godratio
is that a good way tho? i mdan is like my enums but is there a better way more explicit way of doing that. from what i read this is good enough since lisp asigns uniqueid to every symbol
12:51:14
Bike
well, use defparameter instead of defvar i guess. (defparameter foo bar) is just the same as (progn (defvar foo) (setf foo bar))
12:52:54
godratio
ohh ok cool good to know I will do it that way instead and just namespace with naming conventions.
12:53:48
Bike
though speaking of names, you're not following the conventions. dynamic variables (like you declare with defvar/parameter) are named with *asterisks*. multi word identifiers are split up like-this, not LikeThis.
12:53:51
godratio
I was doing at-char for the loop variables but i thinkn for lisp programmers at-cons tehn in the inner loop at-string-cons made more descriptive sense
12:55:04
godratio
ok i see but the token_dash etc… are just being used as enums not global vars thats why i left out the asterix there.
12:55:52
Bike
well, usually you wouldn't even have "enums". you'd just put 'doubledash in the code. it's not like they're opaque numbers like you'd do in C.
12:56:51
godratio
you mean no need to defvars at all? just slam in ‘doubledash wherever i do equality checks?
12:59:37
Bike
You get an error when you have like (cond ((char= #- (first at-cons)) (push ...) (return at-cons)) ...)?
13:04:28
godratio
ok one sec i see where your saying in the docs it says that it should be an implicit progn but still getting a compile error one sec
13:06:32
godratio
https://github.com/godratio/lisptools/blob/5b8b71e952c05e9c980a210167b5b34a8da8ad22/test.lisp#L93
13:11:44
godratio
ahaa ok i see it implicit progn as the whole enclocing form i was confused hehe got it
13:12:24
godratio
The whole form is a implicit prog not just the second parameter which is what my assumption was.
13:26:46
godratio
ok so refactored giving your suggestions one thing i can say is after progn is removed
13:28:32
godratio
or define anything its a bit cray although if you mis typing something could produce a very transparent bug… but than agian even if you define those things doesnt save you
13:37:41
beach
godratio: Why do you want char-count to be a special variable. You are only using it in one place, so it could be a lexical variable. In fact you don't need it at all. (dotimes i (file-length stream) ...)
13:42:05
godratio
the file read in stuff was the first lisp code ever wrote in my life haha so thats why its all messed up i just fixed basd on you suggestions all very good points.
13:42:08
beach
Why is *current-string* a special variable? It is used only in one function, so you can make it a lexical variable.
13:42:41
godratio
regarding (setf at (get-token at)) is to move the conscell forward to the point we advanced by get-token
13:43:39
godratio
well i dont see why not since it seems to move it forward from there on the next iteration by that spiffy loop macro.
13:44:26
godratio
Yes current string iw as trying to use let and it was failing for some reason i had not quite got why i could not get lexical scoping to work the way i wanted will try again to properly understand it.
13:46:23
beach
I am pretty sure it is not specified what happens if you assign to a loop variable in the body of the loop.
13:47:02
solyd
i'm having an issue with managing state / configuration in my lisp code. I've seen plenty of libraries that use global variables like ql:*local-project-directories* to do this but coming from Java/C++ background it strikes me as odd (wrong) to use global variables...
13:47:10
beach
I would try something like (loop for at = (get-token *char-list*) then (get-token at) collect at)
13:47:46
solyd
also, how would i define my functions? (defun send-x (x host port) ...) where host and port should be configured by the library user, should they not appear in the function declaration and just use *host* and *port* defined as globals?
13:49:31
solyd
beach: yes, they are package-local but I'm worried about having the program state scattered across many global variables. I like everything to be contained nicely in meaningful objects...
13:49:55
beach
solyd: You can get the best of both worlds with &optional as in (defun send-x (x &optional (host *host*) (port *port*)) ...)
13:51:44
solyd
mmmm... what about using partial functions? I can create another "layer" of functions that have most of the arguments values assigned to ease development and still have a layer that accepts all possibly required arguments to do the job
13:53:17
solyd
do you have any recommendations on high quality, production, lisp code to read so I can figure out the common best practices?
13:53:34
beach
solyd: The package can kind of play the role of a class instance when you are not expected to have multiple simultaneous instances. So special variables are fine in that case.
13:54:44
beach
solyd: This one https://github.com/robert-strandh/Cluffer is pretty recent so it follows my more recent ideas of good practice.
13:55:24
beach
solyd: You can't have several instances of one particular package. A package is already an instance. If you need to have multiple simultaneous instances, you would use classes instead.