[ art / civ / cult / cyb / diy / drg / feels / layer / lit / λ / q / r / sci / sec / tech / w / zzz ] archive provided by lainchan.jp

lainchan archive - /λ/ - 18486



File: 1473192273433.png (1.24 MB, 300x116, Space-cadet.jpg)

No.18486

This is the Lisp General, ask any and all Lisp questions here. Below is a link to the general's texts which contain many links to various books, documentation, websites, and other interesting information.


>Check the texts first:

https://lainchan.org/~lisp/


>Read the FAQ:

https://lainchan.org/~lisp/faq.txt

>To foster discussion:

Which dialect do you prefer?
Do you use Emacs or a different lisp-based editor?
What was your first experience with lisp?
What have you made in lisp?
What is your favorite Lisp program?
What do you like about Lisp?
How do you think Lisp is (one of) the superior programming language(s)?
How long have you been programming in Lisp?
What are your favorite Lisp resources? Please share, preferably links!
Is Lisp your main programming language or not? Regardless, what do you primarily use it for?
What would you like to see in the Lisp general?
What was your favorite aspect of the Lisp machines?
Do you think we'll ever get something similar to the LispMs again?
What is your preferred method of documenting your code?
In the dialects that allow it, do you make many reader macros or not?
Do you use more than one dialect? What are they and which do you prefer?
What do you consider the criteria for what constitutes a Lisp to be?
What is your favorite function in your chosen dialect(s)?

Challenge:
Write some utility functions or other enhancements that would be useful in other programs.

  No.18510

>>18486
>Write some utility functions or other enhancements that would be useful in other programs.

A simple function that I write to "sanitize" user inputs in my web app.

(defun string-whitespace-cleanup (str)
"Removes all leading and trailing white spaces from a string."
(string-trim #(#\Space #\Newline #\Backspace #\Tab
#\Linefeed #\Page #\Return #\Rubout) str))

  No.18525

Im really annoyed that chicken scheme's ffi can not pass structures by value to C functions. Are there any other scheme implementations that have a friendlier ffi?

  No.18528

How do I set all my macros on REPL startup?

  No.18531

Huge n00b here.

How do I return an expression unchanged without quoting the expression?
I was messing with force/delay that I learned from the SICP lectures and I was trying to do
(defmacro wat (x) `,x)
but when I tried it on (wat (+ 3 3 4 2 3)) it returns 15.

Also how essential is emacs? I use either vim and (load "filename") or just copy and paste.

  No.18532

>>18528
Load the files from the starting file for the implementation. This is .sbclrc for SBCL, as an example.

>>18531
Both of these work:
(defmacro wat (x) (list 'quote x))
(defmacro wat (x) `(quote ,x))

A macro is passed the unevaluated expressions, but what it returns is then evaluated in its place. To avoid that, you need to make the returned expression quote it, to avoid evaluation.

>Also how essential is emacs? I use either vim and (load "filename") or just copy and paste.

Lisp is my main language, so Emacs is rather valuable. If you don't use Lisp as much, you can get away with using a different editor.

  No.18542

>>18531
>how essential is Emacs?

When you are testing stuff on the sbcl interpreter it's very useful to navigate and correct code (I test macros and function behaviour, so it is a must) and Slime lets you do exactly that. You can also surf through your command history.

  No.18545

It's meant to be called from inside another function, with tmp as an empty list. You never know when you'll need to put a symbol between every item of a list.
(define (intersperse lst x tmp)
(if (null? (cdr lst))
(append! tmp lst)
(intersperse (cdr lst)
x
(append! tmp (list (car lst) x)))))

  No.18546

>Write some utility functions or other enhancements that would be useful in other programs.

I've been trying out kawa scheme lately (which is a fast scheme running on the jvm) and wrote this little utility that I use often:

;; Converts all of it's arguments to strings and concatenates them (same as Clojure).
(define (str . args)
(apply string-append
(map (lambda (x) (invoke x 'toString)) args)))

  No.18547

>>18531
I also don't like using emacs so much because I live in the command line and ultimately emacs makes me depart from my usual workflow.
I recently found Ed can somewhat help to emulate that workflow in slime in which you can send a single s-expr to your repl. I am still working on how to make it more seamless because I still do stuff like, in ed:
3,10w defun.lisp
and then go to the repl and do
(load "defun.lisp")
which still means a lot of keystrokes
also slime in vim is awkward and you pretty much have to compile both python and Vim to ensure it will work properly.

  No.18549

>>18547

With vim you can send some text to a tmux or screen session that contains a repl.

It's not quite a replacement for slime though ...

  No.18550

>>18545
That's very interesting, considering I've written my own routine to place an element between elements of a list. Mine is called INBETWEEN.

Here it is:
(defun inbetween (list element)
"Non-destructively insert element between each element of list."
(loop for (i . rest) on list
collect i
while rest collect element))

(defun endless (list)
"Make a list recursive."
(setf (cdr (last list)) list))

I have a small library I'm going to release soon, probably in a few days. It won't be particularly practical, but it will be interesting.

>>18547
Ed isn't very extensible, but you may be able to get away with it, using some sh scripting.

Take a look at these commands:
($)r !COMMAND
(1,$)w !COMMAND
!COMMAND

  No.18551

>>18550
I'll also point out that ENDLESS doesn't like NIL, but this version does:
(defun endless (list)
"Make a list recursive."
(if list
(setf (cdr (last list)) list)))

I should probably retire the other version.

  No.18552

>>18550
This is the Common Lisp equivalent to my function (this time with a wrapper around it):
(defun intersperse (x list)
(helper x list '()))

(defun helper (x list tmp)
(if (null (cdr list))
(nconc tmp list)
(helper x
(cdr list)
(nconc tmp (list (car list) x))))

  No.18555

>>18549
didn't know that, thanks for the tip.

  No.18556

>>18552
You should investigate the FLET and LABELS special operators.

http://clhs.lisp.se/Body/s_flet_.htm

  No.18557

>>18556
I know what they do. For that small snippet it doesn't matter much, but I'd consider using labels in a real usage much as I put the Scheme version as a nested define.

>>18545
This one might be useful to someone too. If you frequent the irc you've seen it in action.
(define *seddy* (make-regexp "^s/(.*)/(.*)/g?$"))

(define (seddy sed str)
(let* ((global (string-suffix? "/g" sed))
(regexp (regexp-exec *seddy* sed))
(match (match:substring regexp 1))
(replace (match:substring regexp 2)))
(cond ((or (string-null? str)
(null? match))
(error *error-list*))
(global (regexp-substitute/global #f match str
'pre replace 'post))
(else (regexp-substitute #f (string-match match str)
'pre replace 'post)))))
It depends on (ice-9 regex), of course.

  No.18558

>>18557
RIP in peas formatting.

  No.18570

bigloo 3.4a soon
https://sympa.inria.fr/sympa/arc/bigloo/2016-08/msg00009.html
Anybody here using bigloo?

  No.18584

>>18570
I can't access this, even using an archiver.

  No.18596

>>18584

Date: Fri, 26 Aug 2016 09:11:57 +0200
Organization: Inria

Dear all,

Bigloo-4.3a is now almost ready. As far as I'm aware of, it runs on all
tested Linux boxes and compiler, Mac OSX, Windows 10, and Android. It would
be nice if you could give it a last try before it goes public next
week.

Thanks in advance,

--
Manuel

  No.18620

Is my automata good CL?
https://github.com/KoltPenny/CommonLisp-automata
I think this is as small as I can make this thing.

  No.18622

Any alternatives to cl-ncurses? That one is pretty much abandoned.

  No.18630

>>18620

There's a typo or missing function definition, parameter names should be surrounded with '*' like (defparameter *MYPARAMETER* nil), and the general code feels too imperative. Go through some beginner resources if you haven't. Getting something small should be the least of your worries and might be misguided. Good effort, keep it up.

  No.18632

>>18630
Oh shoot, I forgot to add the macro:
(defmacro latom (e) `(car (last ,e)))

  No.18633

>>18630
Also, what's the difference between a variable and a parameter? the scope?

  No.18634

>>18620
In your Qs file, the spacing is rather odd. Here's an example I'll dissect: ( q000 (#\0 q000) (#\1 q001))
Generally, the opening parenthesis shouldn't be followed by a space and you don't seem to be using the two spaces for alignment, since the structure would be aligned regardless.
Considering how you're using the q labels, you should strongly consider allowing numbers, symbols, and perhaps any object as allowed labels. You'll avoid polluting the symbol table this way. It also becomes easier to remember how to use this, if one need not worry about the allowed types of labels, even if people won't realistically use, say, a hash table as a label. It would be simple to reason and remember that labels are compared as if by, say, EQL or whatnot.

Your documentation strings are inconsistently formatted. Here's what I would use:
"Execute the relation of pertenence and return a state."
"Check if a string belongs to an alphabet and if it validates a terminal state."

The LATOM function isn't defined and I've at all no idea what it would do, based solely on the name; is it Last ATOM? Because of this, I can't test your program.

Your program is small, so it's hard to reason how this would work in a greater scope, but the global variables seem unnecessary. You can always create local variables and DECLARE them to be dynamic, if you need to.

>>18622
I've actually been considering writing a curses replacement in Common Lisp for a time now and was going to release it, when finished, as part of my challenge.
Because you want one, I'll try to have it soon.
I find it necessary, because memory leaks shouldn't be required nor risked to simply communicate with a terminal.

  No.18635

>>18634
Thanks man, also, latom is this macro:
>>18632
Since I have it already on my system I forgot to add it to the file.

>Generally, the opening parenthesis shouldn't be followed by a space


Yeah, that shouldn't be there

>you should strongly consider allowing numbers, symbols, and perhaps any object as allowed labels


I don't quite get this one but I think you can use pretty much anything as a label because the program just looks for the first or second element so it's type agnostic since it's not doing anything special with them, they are just vertices on a digraph.

  No.18636

>>18634
I made a mistake. I glanced over your use of ASSOC, so that explains why EQL, in particular, came to mind, so ignore that bit about label types.
Regardless, you should change those symbol labels to numbers, sans QE and QO.

>>18632
That clarifies things. That need not be a macro, by the by.

>>18633
DEFVAR and DEFPARAMETER define global special variables. A special variable has dynamic scope. Simply read the meanings of dynamic and lexical scope, if you don't already know.

  No.18637

>>18636
Oh, the labels are like that because that's how they were on the book I'm reading.

>That need not be a macro, by the by.

I have it set as a macro because it's being used a lot in my programs and I just wanted to make my code cleaner by not writing (car(last x)) all the time.

Those variables are supposed to be global, for the sake of data consistency between both functions, but maybe only curr-st should be dynamic. Does the use of ** has a lexical reason or is it just Lisp etiquette?

  No.18638

>>18637
>Oh, the labels are like that because that's how they were on the book I'm reading.
Okay. Regardless, it's not a good idea to pollute the symbol table in such a manner.

>I have it set as a macro because it's being used a lot in my programs and I just wanted to make my code cleaner by not writing (car(last x)) all the time.

You misunderstand. It should be a function, considering it does nothing requiring macro facilities.

>Those variables are supposed to be global, for the sake of data consistency between both functions, but maybe only curr-st should be dynamic. Does the use of ** has a lexical reason or is it just Lisp etiquette?

As written before, local variables can be made dynamic by DECLARE. You should consider doing this or eliminating the need for such variables. I've not yet given the structure of your program too terribly much detailed thought, but I could rewrite it to eliminate these variables or make them local, at the least, if you would care to see how.
It's considered good style by many to give such variables the ``earmuffs''. The Common Lisp standard dynamic variables use this, as an example.

  No.18640

>>18638
>if you would care to see how.

It'd be interesting to see how, I couldn't come up with a clever way to do so.

>It should be a function, considering it does nothing requiring macro facilities.


In which cases is a function better than a macro?

I just changed it, what do you think?

  No.18641

>>18638
I think I've finally done it. Check it out and let me know. If you started working on it by any chance I'd still very much like to see your approach. Let me know what you think of these recent changes, cheers.

  No.18642

>>18641
That's very much improved.

I dropped my rewriting and instead opted to further improve your changes:
(defun automata (query string &optional (stream *standard-output*)
&aux (state (caar query)))
"Check if a string belongs to an alphabet and if it validates a terminal state."
(princ (cond ((find 'nr (map 'list #'(lambda (sigma)
(if (assoc sigma (rest (assoc state query)))
(setf state (car (last (assoc sigma (rest (assoc state query))))))
'nr))
string))
"NOT RECOGNISED")
((find 't (assoc state query)) "SUCCESS")
(t "FAILED"))
stream))
I didn't bother eliminating STATE, although I don't believe it's strictly necessary. I'll leave such to you.

I've some comments on your rewrite:
(let ((states nil) (strlist nil) (curr-st (caar q)))
It's best to initialize bindings when making them, rather than later using SETF. It's cleaner and more easily optimized.
(setf strlist (map 'list #'(lambda (x) x) str))
This can be accomplished with COERCE. The lambda can be accomplished with IDENTITY. Using MAP removes the need to use a list entirely.
Your FORMAT usage is replaced with PRINC. It's better to move common subexpressions out of conditionals, considering each path used FORMAT and the conditional can be made to return the string to print instead.

I don't believe I've made any errors in my rewrite.

  No.18643

>>18642
That is far cleaner, thanks for the advice, it's been very useful. I'll implement some of it later. I don't know why it didn't occur to me to use &aux. Yeah, coerce would remove the need of that lambda.

  No.18666

>Write some utility functions or other enhancements that would be useful in other programs.

The FILE-TYPES system doesn't have a method for adding MIME info to its tables in a live system.
I otherwise like what the library does, though I haven't looked to see if I could improve the rest of it,

;; Making up for the lack of facilities in the file-types package

(defun file-type-hash-append (definition-list &optional (hash-table file-types::*file-type-hash*))
(iterate (for def in definition-list)
(destructuring-bind (key-list &rest body) def
(dolist (key key-list)
(setf (gethash key hash-table) body)))))

An example definition-list you'd give it:
(defvar *extra-file-types*
'((("org")
:tags (:text :org-mode :markup)
:mime ("text" "x-org"))
(("odt")
:tags (:text :libre-office :document)
:mime ("application" "vnd.oasis.opendocument.text"))
(("ods")
:tags (:text :structured :libre-office :spreadsheet)
:mime ("application" "vnd.oasis.opendocument.spreadsheet")))
"File types to make categorization easier")

Translation to LOOP is pretty trivial if you don't like depending on too many external libraries.

  No.18670

Complete newb to Lisp, though I'm interested in it. Might be a basic question but I can't find a definitive answer to it, so I'd like to hear opinions.

Can I learn and program Lisp (specifically, Scheme) without using Emacs? It appears that the two are in some way married, but I hate Emacs on an intimate level. Am I looking at this in the wrong way or do I just have to suck it up and learn Emacs?

sage because quite possibly retarded question

  No.18673

>>18670
emacs is written in lisp, and it's certainly the most ubiquitous environment for developing lisp in, but it's in no way required.

  No.18677

>>18642
I've taken on your conditional to update the code. Made the source smaller.

I was going to ask yesterday but forgot: What is that optional part for?

  No.18678

>>18677
>I've taken on your conditional to update the code. Made the source smaller.
Try not to skimp on lines in such nested code. This is a fairly arbitrary distinction to make, but the code's harder to read with how you've it.
Your Qs file is still using two spaces where unnecessary. Meanwhile, AUTOMATA doesn't have enough spaces, with the following of symbols immediately with parenthesis being rather unidiomatic, outside of code golf.
Lastly, L-STR is unnecessary, considering how simple it is to use MAP in the place of MAPCAR.

>I was going to ask yesterday but forgot: What is that optional part for?

You're printing to a stream and adding the stream as an optional argument didn't interfere with the previous lambda list, as all the arguments for such were required.
This is better than mandating the stream used.

  No.18679

>>18678
Done. It's better without the l-str assigning. I'd forgotten about the Qs file.

  No.18683

Little question about Lisp on Android:

I got myself Termux, a non-root minimal Linux environment because this seems to be the only app that allows me to run my beloved emacs.
However slime requires a lips process, termux only comes with picolisp as installable package, yet slime refuses to acknowledge it (might be because of the weird syntax, de instead of defun and so on).
Anyone knows how it might be possible to compile sbcl and/or asdf so that it runs on android?

I thought about downloading the lisp files for both and have picolisp compile them, but no luck (see: weird syntax).

There is an app called ECL for android but it does not work correctly either (have not tried c&p the whole sbcl.lisp into it yet however)

  No.18684

>>18683
>Anyone knows how it might be possible to compile sbcl and/or asdf so that it runs on android?
download source and compile. it has gcc no? clang?

  No.18685

>>18684
it has clang instead of gcc.
problem is if I call make.sh from the unpacked tarball it throws tons of errors because it expects a real linux, not the kastrati Im on.
most errors are asdf related, so I figured I try compiling asdf manually first, but it throws tons of errors there too, mostly related to missing directory permissions.

So my idea was to use a lisp compiler to compile another lisp compiler, hoping to bypass the gcc/clang related errors.

  No.18686

>>18684
actually there must be ARM binaries on their sourceforge

  No.18689

>>18686
thx.
A bit of more googling indeed got me the arm binaries.
executed chroot and ran sh install.sh, everything worked fine apparently.
Except now emacs cannot find sbcl and neither can I, the directory I installed it to tells me that it is not a directory.
I assume that this is more of a termux problem than a CL one, so I will come back here once I get it to run properly.

  No.18692

>>18685
do you really need sbcl? is it an absolute must?
Because ECL has an android port
https://common-lisp.net/project/ecl/posts/ECL-Android-001.html
You really can't expect to get much done on an android thingy unless you're actually trying to hax it to be anywhere useful.
Anyway, the ecl apk doesn't provide a repl, it just starts swank and listens to a port, so you'll have to figure out how to work with that

  No.18693

>>18692
Wait that changes things, I assumed ECL whas that shitty REPL app from the Play store.

I will look into that, thanks a lot.

I used sbcl because thats what runs on my Laptop so I know that Emacs-slime plays nice with it. As long as emacs is cool with it, so am I.

  No.18763

So for Google Summer of Code, someone worked on a continuous integration server written in Guile. It uses Guix, a functional package manager also written in Guile. https://notabug.org/mthl/cuirass

  No.18766

RacketCon 6 and the 17th Annual Scheme and Functional Programming Workshops are on tomorrow in the US and Japan respectively.

  No.18781

>>18766
are either of them going to have any recorded videos of the presentations posted online?

  No.18786

>>18781
racketcon definitely will via the racketlang YT channel.

scheme and FP workshop is a maybe. the ICFP 2016, the umbrella conference for the workshop will post all of it's talks online.

  No.18816

File: 1474277559020.png (4.63 MB, 200x200, A Practical Introduction to Fuzzy Logic using LISP.pdf)

Question:
I am slowly working through this book (file attached).
They introduce a lisp called NewLisp.
(www.newlisp.org, yes I read through the FAQs and "What sets it apart" they were not very informative)
Has anyone ever worked with it?
Is it worth it? Very different to CL?

  No.18848

>>18816
It is very different than Common Lisp.

  No.18855

What is the best book to learn Scheme?

  No.18856

>>18855

SICP?

  No.18857

Just released a new Common Lisp library. Feels good to get to contribute to the community.

Now waiting for it to get added to Quicklisp...

  No.18858

>>18856
But SICP isn't about Scheme, it just uses Scheme. There are no hygenic macros, no explanation of call/cc etc

  No.18861

>>18855
Probably this:
http://scheme.com/tspl4/

But I would recommend reading The Little Schemer, The Seasoned Schemer and SICP first.

  No.18863

>>18858
>>call/cc
I believe that is in the seasoned schemer.

  No.18877

>>18486
>Challenge:
>Write some utility functions or other enhancements that would be useful in other programs.

I wrote J-style hook and fork functions and convenience macros for easier higher-order function writing.

>Forks

If you want the average of a list, you would normally do something like:
(define (average list) (/ (sum list) (length list)
Assuming your lisp has a sum function. If it doesn't, then you'd just define one use a higher-order function:
(define (average list) (/ (apply + list) (length list)))
Higher-order forking makes it easy to describe a function like this "in terms of itself", without having to bring in extraneous arguments and other (maybe higher-order) functions. The average of a series of numbers in a list is just the sum divided by the length. In prefix notation with forking then:
[code](define/fork average (/ sum length))

>Hooks
Hooks are a little more complicated, you can visualize a higher-order hook as "splitting" (or "hooking") an argument between two functions, and then joining them with a third. I found it useful for defining geometric lines. Another simple example is determining whether a number is an integer. A number is an integer if it's equal to its floor, which os the nearest integer which is equal to or less than the number given:
(define (integer? x) (= x (floor x)))
Using hooks:
(define/hook integer? (= floor))

Anyway, these are both kind of contrived and simple examples, but they're really useful functions and can cut out a lot of boilerplate type code in more extended or complex function definitions.

  No.18885

>>18877
This is interesting, but I feel that I would gain the best understanding by reading the code.
Where is it?

  No.18893

>>18857
Tell us more.
What does it do.

  No.18901

>>18634
I've not forgotten of this, but I've been busy with other tasks.

Regardless, I have some fun programs.

I believe this may be the simplest way to rather irrevocably lock a Common Lisp REPL:
(tagbody loop (handler-case (loop)
(condition () (go loop))))
I was considering the best way to do this, after recalling that (loop) alone would be insufficient and came to this after a few minutes.
Unfortunately, a standard infinite loop doesn't seem strictly possible, as there is potentially a small window of time between the undoing of the condition handler and its reestablishment during the GO control transfer.
If someone can write a better infinite loop, please do. I'd considered nesting the condition handlers, but the window of opportunity still remains.

I was considering my internal thoughts of IF and GO being the decision and looping primitives, respectively, and wondered if this was an incorrect notion of them.
So, I tried to use IF for looping and GO for decision making:
#1=(progn (if (yes-or-no-p "Loop?")
#1#))
This works, but relies on recursion and can't be compiled.

This can be compiled, but still relies on recursion; furthermore, using EVAL feels out of the spirit of this:
#1=(progn (if (yes-or-no-p "Loop?")
(eval '#1#)))

Considering that GO is a special form that won't evaluate its argument, that rules it out as a decision making primitive. Using EVAL with a form such as `(go ,(yes-or-no-p "")) will fail because of the null lexical environment EVAL mandates, as TAGBODY establishes a lexical environment for the tags. Regardless, using EVAL to accomplish this seems to show that GO isn't suitable for such.

I've some other interesting developments, but I'll continue working on them before showing them here.

  No.18921

>>18885
Sorry for the spelling/formatting errors in the previous post. Here's the link to the repo. There's still a few things I'd like to add or fix-up. The readme goes into a little bit more detail about hooks and forks in general.
https://github.com/interplinternet/hooks-and-forks

  No.18949

emacs daemon control script author here.
Mostly consistancy improvements, and fixes for broken quoting:

https://clbin.com/jGW1E

  No.18963

I was talking to an old dude who used to work at area 51 (he never revealed soykaf to me nor did I ever ask). He is a programmer who knows fortran, c, C++, ada. He took some of my code in java,having no knowledge of the syntax but was able to make my program almost 10x better just by making some incredible suggestions.

I asked him what he thought about Lisp, he looked at me with a blank stare and said "Lisp is a programming language for AI's." and he left it at that. What do you guys make of that?

  No.18964

>>18963
Lots of experience wih Algols, never heard but a few words spoken of lisp. Probably witnessed the 80s boom and learned that "Lisp is for AIs", much like in the 20**s we say that PHP is soykaf (true as it may be), even those of us who've never written a single line of it

  No.18965

>>18963
"cool story bro" is what actually popped into my brain after reading your post.

  No.18967

>>18963
Nobody is perfect

  No.18968

>>18949
You might want to add a comment mentioning that setting EDITOR to something other than a path is technically wrong (though it will usually work). For example, in zsh you can't do "$EDITOR file" with "emacsclient -t" as your editor (you have to use eval).

  No.18978

>>18622>>18634
> I've actually been considering writing a curses replacement in Common Lisp for a time now and was going to release it, when finished, as part of my challenge.
I actually need to write simple cli programm.
It would be more like a monitoring tool that displays some stats (i imagine it to look like htop).
Thought it could be a good starting point for learning lisp from beginning (could implement in python as it has curses lib, but that`d be boring), so please count me in.

  No.18985

Do you guys know of any cool lesser known scheme implementations? Gambit is brought up often because it can be fast and has a good ffi, Bigloo because of its ability to call java easily.

I'm interested in smaller alive implementations, for example I stumbled across Sagittarius Scheme http://ktakashi.github.io/sagittarius-ref.html which is really cool. Has a lot of neat utility baked in like CLOS/MOP support and a ton of libraries for what seems to be a one man project. Dev is japanese and I think a lot of the explanations are auto-translated so theres some bumps reading through parts of the manual but overall its high quality stuff.

Theres also Cyclone Scheme that came out a few months ago that is an r7 scheme with native threads, the ffi on it seems pretty limited unfortunately.

  No.18995

>>18985
Ikarus is an optimizing compiler
scheme9 is a small scheme interpreter written in the literary programming style
Stalin... I don't know about this one, I just like the name

  No.19001

>>18670
You don't need to use emacs in order to learn you some Lisp.

This is especially true for scheme, as an example I'm gonna use Racket: You can write Racket (or the Scheme standard in Racket) and just call it from the command line like you would a ruby or python script, or use DrRacket.

Emacs is the most comfortable option imo, since it makes the standard lisp REPL workflow a breeze.

However since you are talking about 'learning' lisp, anything works, scheme is also really pen&paper friendly while learning.

  No.19010

I've started learning haskell for my undergrad course, and was wondering whether Common Lisp (or any other dialects) has anything akin to haskell's pattern matching?

  No.19011

>>19010
Scheme's syntax-rules are the only thing I can think of.
Here's an example (taken from the url at the end of this post), the underscores here mean something different than in haskell, it isn't a catch-all but rather the name of the defined macro (here 'cond'). So thus (cond (else ... )) would be matched by the (_ (else e1 e2 ...)) clause, the ellipsis (...) means 'more of this'.
(define-syntax cond
(syntax-rules (else)
((_ (else e1 e2 ...)) (begin e1 e2 ...))
((_ (e0 e1 e2 ...)) (if e0 (begin e1 e2 ...)))
((_ (e0 e1 e2 ...) c1 c2 ...)
(if e0 (begin e1 e2 ...) (cond c1 c2 ...)))))
The big difference is that these are not functions, but macros, so they take effect before runtime, and they do not run any code, they just translate it to other code.
However the magic of lisp makes it so that you could write your own pattern matching macros for functions to be matched at runtime; I don't know how hard it would be though
Here's a quite long intro
http://www.scheme.com/tspl2d/syntax.html

  No.19012

>>19010
Yes, there is implementations of pattern matching that can be found in various lisps. They might not be as powerful as the ML version of pattern matching, but it close enough.

I am not sure what is the recommended implementation for common lisp though.

  No.19015


  No.19017

>>19010
Racket's default pattern matching is very, very good. I've read that it's more powerful than Haskell's, but I haven't used Haskell enough to speak on this. Either way, I'm sure it's at least on-par with Haskell and ML pattern-matching.

If any Racketeers/Lispers use Haskell, does Haskell's default pattern matching implementation allow:
>matching and binding elements of hash-tables, vectors, regexps
>matching with boolean logic (and pat...) (or pat...) (not pat....) etc.
>applying arbitrary expressions/functions to values to be matched and then matching those within the same pattern-matching clause
>escape clauses for arbitrary conditions defined within the clause (=> ....)
>matching arbitrary named fields of a struct, including single fields
I guess it's kind of a moot point, since Racket has derived-patterns and match-expanders that allow you to easily extend pattern-matching as far as you want using a macro extension. It's got a lot of conveniences too, but I'm sure those exist in Haskell as well, like creating lambdas with pattern-matching bodies, let-expressions generalized to use pattern-matching, etc.

  No.19035

Hello lisp-lains, I am currently getting started with Common Lisp and trying to figure out how to launch programs.

I am trying to launch an external program and grab its output, so that its shown in the current stdout (also: not after the process finished, but while it runs), in this case I am trying to launch mpv and get the information mpv prints itself while running.

I manage to launch mpv by using (sb-ext:run-program "mpv" '(<MY VIDEO>))

However this will not get me mpvs output, setting `:output t` does not seem to do anything.

Can someone help me with a small working example? Is this this even possible without writing a loop that continuously checks the output stream? Sorry for my lack of proper vocabulary.

  No.19036

>>19035
You don't seem to have read the SBCL manual in detail.
_':output'_
Either 't', 'nil', a pathname, a stream, or ':stream'. If
't', the standard output for the current process is inherited.
If 'nil', /dev/null is used. If a pathname, the file so
specified is used. If a stream, all the output from the
process is written to this stream. If ':stream', the
'process-output' slot is filled in with a stream that can be
read to get the output. Defaults to 'nil'.
Use :output *standard-output*.

  No.19037

>>19036
I did, but I don't read from the description that there is a global variable for the standard-output, as I said I'm a common lisp beginner.

Thanks though.

  No.19038

>>19037
My eyes glazed over that. I wasn't trying to come off as rude.

You'll want to look over some libraries so your programs aren't married to SBCL.

  No.19040

>>19038

No problem, guess the concept of there being a defined standard-output stream is common sense after all.

  No.19041

>>19040
Also, look into the WITH-OUTPUT-TO-STRING macro for tasks such as this.

  No.19044

What's the difference between Lisp's (and other language's) pattern matching and parsing in the classic CFG grammar sense?

  No.19049

>>19044
Well, Common Lisp's grammar is largely defined in terms of reader macros, which are characters bound to run arbitrary programs when encountered, optionally not if in the middle of reading a symbol.

So, the parenthesis are just reader macros which construct a list, as an example.

  No.19053

>>19049

I see. That does make sense to me. I still don't understand how it compares to formal grammars, though.

I'm asking all this because I'm reading RFCs and programming language standards and all sorts of specifications. They make heavy use of formal grammars. I started studying them and I can't help but wonder why people even bother. There's got to be some kind of advantage to using actual grammars, right? Most programming language implementations I've explored have at least one incomprehensible .y file chucked somewhere in their repository. So, people are making use of this technology...

The more powerful a grammar formalism is, the more similar it is to an actual programming language... And yet they still can't do anything even remotely interesting. Many interesting languages out there are context-sensitive in a way that simply can't be described by any formalism I know of.

The papers on this subject are some kind of elaborate torture for the mind. People come up with all sorts of fancy, proven-correct, generalized parsing algorithms. I would study them, decoding preposterous amounts of academic symbols in the process, only to realize that they can't parse a popular programming language or a simple binary format by themselves. They need help from an actual programming language to do it. So what's the point?

I was just thinking... What would a Lisp programmer do? This sounds like something right up their alley. Would they ignore all this computational linguistics literature?

In concrete terms... How would a Common Lisp developer approach the problem of parsing:

1. The C programming language, or some reasonable subset of it?

Suppose I wanted to automatically extract definitions from header files after correctly evaluating all preprocessor directives...

It pains me to even imagine how I'd try to solve this with a formal grammar. I think even actual C compilers don't do this...

2. Checksummed save data from an SNES game?

Suppose I wanted to make a save game editor for a game that verifies integrity of the data before loading it.

A grammar for the save format would be context-sensitive since the checksum depends on all previous input. It'd have to somehow encode the semantic relationship between the checksum and preceding tokens. However, the grammar can't even compute a checksum to begin with...

3. A length-prefixed array of UTF-8 characters?

This grammar is partially defined by the input. It would have to read the length token, somehow reify that token so that it becomes an unsigned integer and then use it to somehow change the grammar itself, causing it to read exactly that many tokens. Sounds like extremely simple metaprogramming to me.

  No.19057

What makes you all choose CL over racket? I see a more active community on the racket side, a huge amount of usable DSL's/#lang's, and apparently its macro system is the most advanced. I'm asking since I've completed symbolic intro as my first ever programming book and am now trying to figure out where to go. soykaf is weird.

  No.19060

>>19053
>I see. That does make sense to me. I still don't understand how it compares to formal grammars, though.
Wouldn't it merely be an informal grammar?

>I'm asking all this because I'm reading RFCs and programming language standards and all sorts of specifications. They make heavy use of formal grammars. I started studying them and I can't help but wonder why people even bother. There's got to be some kind of advantage to using actual grammars, right? Most programming language implementations I've explored have at least one incomprehensible .y file chucked somewhere in their repository. So, people are making use of this technology...

Grammars are good for the person reading the specification to understand the grammar. This is enough reason to use it, but grammar generators are also popular in some circles, as well.

>The more powerful a grammar formalism is, the more similar it is to an actual programming language... And yet they still can't do anything even remotely interesting. Many interesting languages out there are context-sensitive in a way that simply can't be described by any formalism I know of.

Simply being possible makes a grammar formally specifiable to some degree.
I may be using a different meaning of ``formal'' here.

>The papers on this subject are some kind of elaborate torture for the mind. People come up with all sorts of fancy, proven-correct, generalized parsing algorithms. I would study them, decoding preposterous amounts of academic symbols in the process, only to realize that they can't parse a popular programming language or a simple binary format by themselves. They need help from an actual programming language to do it. So what's the point?

Many aspects of current computer science can be likened to torture.
You'd do good to keep in mind that someone is probably being overpaid to write a paper like that.

>I was just thinking... What would a Lisp programmer do? This sounds like something right up their alley. Would they ignore all this computational linguistics literature?

I like reading papers and standards concerning computation and whatnot, but these parser papers do sound quite drab.
Forth is another language I'm very fond of and so I'm inclined towards being as close to simplest as possible.
Here's an aphorism of mine: If your grammar is complicated enough for you to even consider automatically generating the devices for it, then it is too complicated.

>1. The C programming language, or some reasonable subset of it?


Well, C is largely based around keywords and some special characters, so I'd scan for those to recognize context and whatnot. This first challenge is rather vague to give a satisfying answer to.

>2. Checksummed save data from an SNES game?


Read in the bytes, combining them as necessary. Then use appropriate tests and complain if any of them fail.

Treat it like an algebraic object. If the value of the variables don't solve the equation, the values are incorrect.

>3. A length-prefixed array of UTF-8 characters?


UNICODE is gross. Anyways, it sounds like you've this one figured out.

It seems like the focus on this parser research is achieving some arbitrary quality for certain properties. A tiny little program that would take years to prove correct, if possible, but actually works and works well is infinitely more useful.

Mankind went to the moon with heavy testing and good sense, not formal verification and other drivel. I could be wrong, but this sounds good, anyways, so apply it to some other situation if I'm wrong.

  No.19061

>>19057
Racket is more centralized, with more centralized communications channels, which is probably part of why it's discussed less here.

I'm generally wary of most languages that aren't standardized, but Racket is ported to a fair amount of platforms and whatnot. Racket is similar to Emacs Lisp, in these regards.

>I'm asking since I've completed symbolic intro as my first ever programming book and am now trying to figure out where to go. soykaf is weird.

Peruse this: https://lainchan.org/~lisp/

  No.19067

>>19060
>UNICODE is gross

Why do you say that

  No.19071

>>19067
UNICODE is backwards compatible with ASCII which I also dislike, different languages benefit greatly from using their own specialized encodings, it's only growing more complicated, it's being filled with silly drawings and now several of those are even being politicized, and UNICODE must be filtered in several applications such as imageboards to ensure that controlling characters aren't used to cause strange effects.

As an example, the Chinese language benefits greatly from using its own encodings, considering 17 bits would be sufficient to store any recognized Hanzi. It would probably be considered worthwhile to create a length-varying encoding so that the most common characters can be stored more efficiently.

In the case you ask why I also dislike ASCII, 1/4 of the standard 128 characters are generally only useful on hardware older than Lisp or software emulating that hardware. The other half of the set afforded by the 8-bit byte is a mess, with everything's it's been used for throughout the decades.

I do have some older hardware supporting an extended ASCII and I very much like that hardware, so don't believe I'm degrading anything that used it well. It's simply not suited for use anymore. It's an inefficient relic of the past kept because of inertia.

If I wouldn't want to use a library to handle parsing a language, why would I want one merely to handle a character encoding properly?

Do you like UNICODE? If so, why?

  No.19072

>>19071
>Do you like UNICODE?

Yes

>If so, why?


Because with Unicode there is no real need for any other encoding, for the first time ever you can easily encode any conceivable symbol and tons more, data compression algorithms pretty much defeat any storage/transmission efficiency arguments, you can process text in an uniform manner without transcoding, it's essentially the foundation of any respectable i18n software, it has tons of metadata for each symbol that's useful for transforming text, its locale-aware, it was made by smart people who considered linguistic and cultural issues I didn't even know existed and came up with good solutions, it inherently forces subpar programmers to realize the bitter truth that text isn't actually a char array

  No.19073

>>19071
>If I wouldn't want to use a library to handle parsing a language, why would I want one merely to handle a character encoding properly?

it should be handled at the language level honestly. strings should be unicode. I was extremely disappointed with R7RS when I saw it wasn't required, they lost their chance to dramatically and unambiguously improve scheme

  No.19074

>>19072
>Because with Unicode there is no real need for any other encoding
I could just as easily claim that with Intel, there's no need for any other CPU type.

>for the first time ever you can easily encode any conceivable symbol and tons more

If it sounds too good to be true, it probably is.
Just as with extremely accurate time keeping, written language will continue to use custom solutions at the first hint of insufficiency.
Furthermore, UNICODE could be considered a case of strangling the specific for the benefit of the general.

>data compression algorithms pretty much defeat any storage/transmission efficiency arguments

No. Compression isn't a magical cure for inefficiency. Furthermore, that compression takes time and space to use.
I particularly enjoyed Chuck Moore's pseudo huffman-encoded character set he used for colorForth.
Donald Knuth's MIX character set is also rather elegant.

>you can process text in an uniform manner without transcoding

I don't find that particularly impressive, especially considering the amount of computer text that exists still not using UNICODE nor ASCII.

>it's essentially the foundation of any respectable i18n software

The Common Lisp standard rather explicitly favors English with several of the FORMAT clauses it provides.
I like adhering to as few standards or guidelines as reasonable and possible.
Making computing more accessible for those not knowing English is a noble goal, but English is practically the lingua franca of the Earth.

>it has tons of metadata for each symbol that's useful for transforming text

I suppose that's nice, but I shudder at the complexity of that.

>its locale-aware

Okay.

>it was made by smart people who considered linguistic and cultural issues I didn't even know existed and came up with good solutions

It's funny that you write this, because I recall the controversy with Chinese and Japanese caused by conflating similar characters.

>it inherently forces subpar programmers to realize the bitter truth that text isn't actually a char array

In Common Lisp, text is an array of characters.
In a system only designed to process English, a letter can be stored with five bits. Six bits could be used to add punctuation and numbers.

>>19073
>it should be handled at the language level honestly.
That's the only reason any program I write would behave with it properly.

>strings should be unicode. I was extremely disappointed with R7RS when I saw it wasn't required, they lost their chance to dramatically and unambiguously improve scheme

I'm going to disagree here. Common Lisp is built around portability, so a :UNICODE symbol in *FEATURES* would be sufficient for any program that needed it. Regardless, I don't write any programs to assume anything but the standard character set.

I believe much of this garbage in computing is going to die at some point in the next few decades. It would be bad for any language to support standards that aren't rather inherent, such as TCP/IP or UNICODE. Even Common Lisp's character set is a subset of ASCII with very few constraints.

  No.19075

>>19074
>No. Compression isn't a magical cure for inefficiency. Furthermore, that compression takes time and space to use.

we live in the age of tens of terabytes as well as transparently encrypted filesystems. these performance concerns simply don't matter anymore.

the fact is your browser is going to compress the text using modern algorithms and the size of the result will be statistically indistinguishable from any other encoding

>especially considering the amount of computer text that exists still not using UNICODE nor ASCII


you mean the text that will become unicode the second it enters your system, if the developer has any sense? man you people must really enjoy mojibake in your database

>English


unicode is about so much more than just supporting a bunch of different languages, but it totally does that.

and because it does, you can mix multiple languages in the same text, because even english borrows words and symbols from other languages. hell there are math symbols in unicode

anything other than unicode is catastrophic to the user experience. there's a reason even programming language symbols support unicode now. there's literally no reason they shouldn't

>I shudder at the complexity of that


its just metadata associated with each character. unicode's already taken care of everything, its all been figured out. using anything else is the same as using your own incomplete buggy date/time library

>controversy with Chinese and Japanese caused by conflating similar characters


good thing the unicode people dealt with that instead of letting that issue bubble up to my code, im hardly the most qualified person to solve that kind of problem and id hate to be put in that position

>In a system only designed to process English


In a system that should be derezzed from ever talking to another computer via the network, ever*

>I believe much of this garbage in computing is going to die at some point in the next few decades.


if you're including unicode in that set then I have no words. Common Lisp is more likely to disappear than unicode ever will be

  No.19076

Before someone objects that unicode is so bad that it going away is inevitable, let me just point out that ASCII is so bad it can't even represent all *English* text, and it's been around since the '60s. For example: "café", "naïve" (not to mention the many punctuation marks it doesn't have).

  No.19079

>>19076
what a delusional objection. overruled

  No.19082

Some questions from my side:

Is it bad style to treat `defclass` and classes simply as slightly better structs with more features? (default values for example)

What is the advantage of methods over functions? Does a "self" reference exist in Common Lisps CLOS? How are methods even called, the same way as functions?

  No.19088

What are some formatting standards present in Lisp?
It seems like a language I could get confused by real easily by bad tabbing/spacing

  No.19090

>>19082

Also: Are there performance differences in "defstruct" vs "defclass", as in: Does it make sense to only use "defclass" if I need the CLOS features because "defstruct" offers better performance?

  No.19093

>>19088
The joke is to use whatever indentation Emacs gives you.
I usually do, unless I'm using a weird macro like LOOP.
I only use spaces. Look into indent-tabs-mode.
Use a space before an opening parenthesis, but not after. This is reversed for closing parenthesis and doesn't apply to consecutive parenthesis. As an example: ((symbol) ())
Use newlines if the expression seems like it needs them. I generally allow one level of nesting before using newlines. As two examples, this is fine (+ (- 1 2) 3), but this isn't (+ (- 8 (+ (sqrt 100) 3)) 5).
I prefer to place simpler expressions before those more complicated. As an example, I prefer this (list 1 (example)) to (list (example) 1).
If you've any more specific questions concerning this, just ask.

>>19082
>>19090
>Is it bad style to treat `defclass` and classes simply as slightly better structs with more features? (default values for example)
I suppose so.
Structs are significantly more restricted, such as not being able to be redefined. Classes also integrate heavily with CLOS and allow for many niceties, such as argument typing through methods.
Structure constructors are inconvenient and less powerful when compared to custom wrappers around MAKE-INSTANCE.

>What is the advantage of methods over functions? Does a "self" reference exist in Common Lisps CLOS? How are methods even called, the same way as functions?

Ease of typing is one aforementioned advantage.
I'm not familiar with the concept of the self in ``normal'' object-orientation, but I believe I recall reading that it doesn't exist, not by default anyways. As with the rest of Common Lisp, virtually everything about CLOS is customizable.
You may want to look at DEFINE-METHOD-COMBINATION: http://clhs.lisp.se/Body/m_defi_4.htm

>Also: Are there performance differences in "defstruct" vs "defclass", as in: Does it make sense to only use "defclass" if I need the CLOS features because "defstruct" offers better performance?

Defstruct is probably going to be implemented as an opaque vector of sorts, unless a type is explicitly defined. An instance of a class is probably going to be implemented similarly. Use INSPECT on these objects to gain more insight for what your chosen implementation does.
I really wouldn't recommend using DEFSTRUCT at all. Most anything you're wanting to do would probably fare better with CLOS.
If you've any more specific questions concerning this, just ask.

  No.19097

>>19093
I see, thank you very much for your answer!
I actually got a follow-up question:

Lets say I got a class

(defclass myclass ()
((field1 :initarg :field1
:initform 1
:accessor field1)
(field2 :initarg :field1
:initform 2
:accessor field2)))

Is it possible to make an additional slot so that when I access it, it will return a list of the other slots?
I know that I could write a function for this, but I am wondering.

Something like

(defclass myclass ()
((field1 :initarg :field1
:initform 1
:accessor field1)
(field2 :initarg :field1
:initform 2
:accessor field2)
(fields (list field1 field2)
:accessor fields)))

  No.19099

>>19097
>Is it possible to make an additional slot so that when I access it, it will return a list of the other slots?
It's a strange omission, but I don't believe so.
It's such a strange omission, that I keep believing I may simply be overlooking some of my material whenever I think about it, but I believe it simply isn't provided.

Luckily, you're able to implement it yourself in whatever way you want. You could write a DEFCLASS macro that abstracts over the default DEFCLASS along with the other macros, choose not to and allow for class redefinitions to, say, choose the slots that are visible and so have ``hidden'' slots, or something entirely different. It's yours to decide.

  No.19105

>>19010
I don't know why no one has mentioned trivia yet (optima's successor: https://github.com/guicho271828/trivia).

  No.19106

>>19057
There's plenty of other things to take into account (like the language itself, performance, what your application will do, the availability of relevant libraries, etc.).

> apparently its macro system is the most advanced


If by advanced you mean "powerful," then no.

  No.19112

I was wondering what you guys thought of Julia? I've been using it for a couple weeks now for physics-related stuff and I'm really liking it. It feels really lispy.

The main differences is that it uses begin/end reserved words instead of opening and closing parens for macro calls, and uses function(args) syntax for function calls. It also allows some infix operators which are translated into prefix notation in the first step of parsing. Apart from these slight differences, it feels really lispy and everything is a disguised sexpression so it is homoiconic. You have full access to lisp macros and community libraries make good use of them.

With that said, I have only used it for a couple weeks or so. I was wondering if any lisp users here had an informed opinion about it?

  No.19123

>>19112
>PyCall

That's insanely interesting. I know how FFI to the underlying OS would work, but Python?

Can one call into a running CLR or JVM too?

  No.19126

>>19099

That makes sense, thank you.

I tinkered around a bit more and another question came to me:

Can I assume that I always work with references unless I specifically copy objects and structures?

An example:

- I got an object A that contains the slots a b c
- I create a new list, lets call it L, of these slots
Is this list now a list of references to to A's a b c values? Or did I copy their value into this new list?

- I make a destructive changes on the contents of L, will these changes apply to A ?

  No.19127

>>19126
>Can I assume that I always work with references unless I specifically copy objects and structures?
Yes.

Read about the EQ function to get more information about this. EQ isn't required to work for characters and numbers, for reasons of efficiency and whatnot. So, treat a number or character from a slot like it's the same, just as you would for any other data in a slot. Notice that you can't transform a number or character anyways. You can't make two become four, so you'd have no way to affect the slot to begin with.

  No.19135

>>19123
I believe this is possible for Java, yes.
http://juliainterop.github.io/JavaCall.jl/

For the CLR, all google results I found were related to calling Julia code from C# since Julia is the faster language, so I didn't find anything. I wouldn't be surprised if it existed.

  No.19136

>>19112
I recently rediscovered Julia and I think its one of the best PL projects to emerge in a long time. It just does a lot of things right, and its made to be useful, not just PL wankery. Dynamic JIT + type inference is brilliant. If I did more technical computing and statistics, I'd be using Julia full-time.
However for the kind of things I do, Lisp and C++ are the right tools available.

  No.19139

>>19135
So it takes a Python/Java virtual machine and puts in the Julia process, and is thus able to interface with it. This is pretty awesome. CLR supports it as well:

http://stackoverflow.com/questions/2348207/what-is-clr-hosting

To think you can take any language and let it interface with Python/Java/.NET...

  No.19147

>>19139
Well, as far as ffis to other languages go, the example that impressed me the most was interfacing with mathematica. Remember, macros can use ffi's too...

Using the mathematica.jl package to interface with mathematica, you can do stuff like:

using Mathematica
@Integrate(x^2, x)
#=> :(*(1//3,^(x,3)))

@Integrate(log(x), {x,0,2})
#=> :(+(-2,log(4)))

...which is a really cool use of lisp macros and sexpression manipulation.

  No.19148

>>19147
Really? I thought many languages had that. Mathematica is very easy to interface with from any language since it separates the "kernel" from any front-end and allows you to access it however you like via MathLink and Wolfram Symbolic Transfer Protocol. There's been interfaces written for TCL, C++, Haskell, SQL (???), Python, Racket Lisp, C, Java, .NET languages, it even allows interfacing via XML.

  No.19149

>>19148
What impressed me wasn't necessarily the fact that I could call it. The thing that caught my eye was the fact that it returned a quoted sexpression.

  No.19150

>>19149
...and that it took a regular sexpression as an input halting its evaluation, just like any other macro. I've called mathematica from outside before (though not from a lisp) and it never quite felt this natural.

  No.19151

>>19149
Honestly that doesn't look like a '(quoted sexpr) much.
Also remember that every language is internally translated to an AST that looks pretty much like lisp s-expressions

  No.19152

>>19151
: is the quote symbol in Julia. :(...) is the literal for a quoted expr.

It is a core Julia data type into which all Julia code is parsed. It can be and frequently is manipulated by Julia functions. It can be fed into eval(), and it is the key focus of macro-writing making the language itself programmable. It is very obviously a quoted sexpression.

  No.19153

>>19152
More specifically, :( ... ) means the same thing as (quote ...) in most lisp dialects.

  No.19161

>>19147
Well as neat as that is there's just no competing with the usefulness of having a foreign interface for Python, Java and .NET. With that ability, pretty much any language can be relevant since day one.

What truly impressed me is the Conda package that somehow installs and manages a local instance of Python for Julia's exclusive use. How amazing is that? I wonder how robust it is. I had trouble installing Python using the official installer; it'd always try to install Windows updates and fail.

  No.19162

>>19152
> It is very obviously a quoted sexpression.
you just want to get on my nerve there.
Anyway, I'm not just talking about the colon but about the expressions themselves. I don't know any julia. I might agree that the 1//3 part is a symbol for, a rational just like in every other dialect, but the commas, and the *(...) thing looks more like the function calling syntax in just about every other language:
[code]
foo(arg1,arg2)
+(-2,log(4)
[/spoiler]
So what I'm saying is that it doesn't look much like lisp really, again, I don't know any julia.

  No.19171

>>19161
Agreed, for general programming having access to Python/Java/C# etc etc is huge.

I found the Mathematica example interesting mainly because of how it showed that macros can also directly benefit from FFI, not just functions. Also, using macros to manipulate math expressions directly as quoted code was cute.

And yes, Julia's package manager is really, really good at installing third-party dependencies. That's a huge plus for scientific computing where the dependency trees can be pretty crazy.


>>19162
Right, the syntax normally used for calling is foo(args) instead of (foo args). But that is something you can have in Scheme and CL as well using things like sweet-expressions. The difference is mostly cosmetic.
( http://readable.sourceforge.net/ )

  No.19173

Since the discussion has turned towards Julia, I thought people here might be interested in this article: http://p-cos.blogspot.com/2014/07/a-lispers-first-impression-of-julia.html

  No.19174

If Julia is a Lisp, why doesn't it even call itself a Lisp?

I don't understand how one could tell themselves this is a Lisp:
function mandel(z)
c = z
maxiter = 80
for n = 1:maxiter
if abs(z) > 2
return n-1
end
z = z^2 + c
end
return maxiter
end

function randmatstat(t)
n = 5
v = zeros(t)
w = zeros(t)
for i = 1:t
a = randn(n,n)
b = randn(n,n)
c = randn(n,n)
d = randn(n,n)
P = [a b c d]
Q = [a b; c d]
v[i] = trace((P.'*P)^4)
w[i] = trace((Q.'*Q)^4)
end
std(v)/mean(v), std(w)/mean(w)
end

Reserved keywords are something I'm glad Lisps and other languages, such as Forths, omit. It's a rather key quality to have in freedom and it saves the programmer from the bother of remembering the special names that can't be used for anything but special reasons.

This seems as compelling as the arguments that JavaScript is a Lisp, which is not at all.

  No.19175

>>19174
Because while it doesn't immediately look like a Lisp, it really does start looking like a lisp when you read the end keywords as ) and realize that they are there for the specific purpose of making macros practical.

By design it is very difficult to write Julia code that can't be straightforwardly mapped to S-expressions. The restrictive scoping rules are designed to make it easy to translate local = assignments into let-forms, etc etc.

Once you look past the surface level syntax, you realize that Julia is indeed a disguised lisp like Dylan. The language is homoiconic and gives you the full power of lisp-like macros, unlike say, Ruby.

  No.19179

>>19171
>And yes, Julia's package manager is really, really good at installing third-party dependencies.

Sounds like other projects could benefit from that knowledge. Any text explaining how it works?

  No.19180

>>19175
>Because while it doesn't immediately look like a Lisp, it really does start looking like a lisp when you read the end keywords as ) and realize that they are there for the specific purpose of making macros practical.
I can easily redefine the parenthesis in Common Lisp. Is a Julia programmer able to redefine these keywords? How many keywords are there? What do these keywords do?
A large part of Lisp is the syntax, which is very easy to parse. Does Julia have any of this ease? Why are macros considered impractical? Do macros resemble functions, as they do in Lisp?
Please provide a rather definitive example of a Julia macro. I'd prefer to see a looping structure added to the language, such as DOTIMES provides.

>By design it is very difficult to write Julia code that can't be straightforwardly mapped to S-expressions. The restrictive scoping rules are designed to make it easy to translate local = assignments into let-forms, etc etc.

Okay. How convenient would it be to use the actual let in Julia, so one doesn't bother themselves with writing so many equals signs?

>Once you look past the surface level syntax, you realize that Julia is indeed a disguised lisp like Dylan.

I've not read any of the Dylan reference manuals. I find the Dylan claims to be questionable.

>The language is homoiconic and gives you the full power of lisp-like macros, unlike say, Ruby.

Being homoiconic and providing metaprogramming doesn't make a language a Lisp.

  No.19183

>>19180
Yes, here's a dotimes macro implemented in Julia:
[code]
macro dotimes(n, body)
quote
for i = 1:$(esc(n))
$(esc(body))
end
end
end
[\code]

Macros can either be used with a function-like syntax if you'd prefer your code to look lispy...
[code]
@dotimes(2, println("hi there"))
hi there
hi there
[\code]

...or they can be used with the alternative algol-like syntax if you want your code to be more readable to people familiar with python or matlab:

[code]
@dotimes 3 println("hi there")
hi there
hi there
hi there
[\code]

[code]
@dotimes 3 begin
for i in 4:6
println("i is $i")
end
end

i is 4
i is 5
i is 6
i is 4
i is 5
i is 6
i is 4
i is 5
i is 6
[\code]

  No.19206

>>19180
>A large part of Lisp is the syntax
I disagree with this. You're focusing too much on syntax, while semantics is much more important and distinctive feature of Lisps.

  No.19219

I still browse hckrnews daily to look for lisp related links, shame that this announcement got zero comments there
http://abcl-dev.blogspot.com/2016/10/abcl-140.html

  No.19222

>>19219
I also noticed this. Checking, it still has no comments.

Of course, it's not something relatively useless or hip so that helps explain this.

On the topic of ABCL, I'm thankful that it exists for when I need to interact with Java. Does anyone have particular experience with it and can tell me of how they fared when using it for this purpose?

  No.19329

Disclaimer: I am in no way well-educated in the field of programming.
So, I was curious about LISP for quite some time and I have one question.
Can you actually compile LISP into binary like you do with C, for example?

  No.19330

>>19329
you most certainly can.

  No.19333

>>19330
Really? Without telling people "So, to launch my program you have to install this run-time..."?

  No.19335

>>19333
yes and no.
yes you can, but the compiler such as sbcl will simply be included into the runtime.
Like the JVM actually.
The user sees nothing of that, the program size is still manageable as only the bare minimum of utilities and libs will be included.

Commercial Lisps such as Allegro have more elegant ways of doing this if I recall correctly.

  No.19336

>>19335
isn't it possible to unintern the symbols that implement all the unneeded stuff?

  No.19339

>>19329
There are some Lisps that compile to C which of course produce executables

  No.19342

>>19336

SBCL does not have a tree shaker, no.

The commercial lisps do. I know that LispWorks does.

  No.19348

To answer the questions at top:

I prefer Scheme (Chicken, mostly, Guile sometimes. I can't stand Racket for some reason)

I code in Emacs, using Geiser and Paredit.

My first experience with Lisp was picking up The Land of Lisp at the age of about 10, looking it over, and squinting to figure out what the code was doing. I picked up scheme in earnest a few years later, and the rest was history.

I'm currently working on an implementation of Thud that can be played over a network. Just because.

  No.19366

Does anyone use CL/Racket/Scheme for backend development?

  No.19397

>>19366
I REALLY want to, I think Racket would be excellent for backend web developement, however the job I'm applying for requires I learn flask (python), which is hideous, I have Jinja, but that's just how the world is.
I'll work on a Racket web server with pattern-matching based routing, and x-expressions, when I'm finish with my little project I'm working on now.

  No.19414

>>19071
>>19074
>>19079
There is but only one way to do charset handling right - use UTF-8, and UTF-8 only. To accept any other charset involves massive complexity and duplication that wouldn't have happened in the first place if you just sucked it up and used UTF-8. Sadly Windows is stuck with the UTF-16 kludge.
>different languages benefit greatly from using their own specialized encodings
So we can go back to the days of "chcp" and converting files to and fro specific charsets? I can pick up any UTF-8 file and cat it and it will look alright, provided I have the fonts installed if it's in Chinese/Japanese/Korean. How you compensate for multi-language contexts? Just the front page of Wikipedia tests how far a system's internationalisation support goes.
>ASCII
Nowt much we can do about ASCII, since 99% of plain text files are in ASCII. Besides, we'd still be stuck in that multiple charset world if we still only had UTF-16 (UCS-2) and Rob Pike and Ken Thompson hadn't invented UTF-8 (on a restaurant napkin, no less).
>English is the lingua franca of the world
More than 90% of the world's population doesn't speak English. Besides, how do you accomodate children into the equation?
>I believe much of this garbage in computing is going to die at some point
Maybe the emojisoykaf will die, but Unicode is too much of an effort to be thrown away at this point, but hey! Back to iconv and chcp and charset barriers, hurray!

  No.19435

>>19414
>There is but only one way to do charset handling right - use UTF-8, and UTF-8 only.
What a convenient solution. Why not only use Windows and so solve all of the other incompatibilities?

>So we can go back to the days of "chcp" and converting files to and fro specific charsets? I can pick up any UTF-8 file and cat it and it will look alright, provided I have the fonts installed if it's in Chinese/Japanese/Korean. How you compensate for multi-language contexts? Just the front page of Wikipedia tests how far a system's internationalisation support goes.

Vomiting a file isn't a useful operation, unless you live in a world like UNIX in which most applications are as if baby birds, eagerly holding their maws agape, awaiting for a slurry of bytes that they can process and then dispose of into yet another eager mouth.

Wikipedia isn't normal text. I can go on and on about my dislike of the representation of text and whatnot in modern systems, but I'll simply say that specialized formatting should be used. Wikipedia, ignoring its flaws which have it being mostly unsuitable for its purpose, should be a dedicated application handling this, rather than a website, just as GNU Info is.

>Nowt much we can do about ASCII, since 99% of plain text files are in ASCII.

I really don't care for the poor encoding from the 1960s. I'd rather use a good encoding in an isolated world.

>Besides, we'd still be stuck in that multiple charset world if we still only had UTF-16 (UCS-2) and Rob Pike and Ken Thompson hadn't invented UTF-8 (on a restaurant napkin, no less).

I'm aware, and what an appropriate place to design it. UNIX was designed on an old computer intended for casual use, only to kill better systems like a plague, and UTF-8 was designed on a napkin and is resisted by many areas that don't already use English as one of the primary languages.

>More than 90% of the world's population doesn't speak English. Besides, how do you accomodate children into the equation?

I don't understand what you're asking. I like the idea of computing as an English discipline, no different than calligraphy. So, learn English or struggle, as it goes. No amount of translation will permanently solve this ``problem''.

>Maybe the emojisoykaf will die, but Unicode is too much of an effort to be thrown away at this point, but hey! Back to iconv and chcp and charset barriers, hurray!

I'm disgusted that I use a laptop based on a personal computing standards from the 1980s, emulating hardware from before the 1950s, to run an operating system designed for an old machine in the 1970s.
I'm disgusted with the lot of it and it will collapse under its own weight some day. I would rather love to have my own environment that isn't concerned with any of this garbage, which is something I'm working towards in my spare time.

One of the nicer qualities most Lisps have is their true portability, meaning that there's very little tying them to the current computing paradigms.

  No.19436

>>19414
I agree entirely. I don't even mind emojis being in the standard. I think complaining about that is misguided. The Unicode standard exists so that anyone wanting to represent a grapheme or glyph has an agreed-upon representation for a series of code points. You don't have to implement them, and there's no requirement that any font implements more code points than its author wants to include. If you don't emojis in your fonts, just don't implement them. If you do want to implement them, then there's an already agreed upon representation for you to follow so that all other users or systems communicating with yours can interpret it correctly.

  No.19443

>>19366
I built a small application using a continuation based web server in Racket. It wastes about 100Mb of RAM doing dick all. I need a better server.

  No.19450

>>19435
Yeah, I hope your programs stay in your own isolated world. The rest of us would rather not solve this encoding problem anymore. Unicode has already reached "Right Thing" status for us. There's nothing that can justify replacing Unicode with whatever ad-hoc encoding schemes you come up with

If you're writing text processing programs and you can choose the output's and the underlying representation's encoding, the only good choices are UTF-8 and UTF-32, pretty much nothing else matters

>Wikipedia, ignoring its flaws which have it being mostly unsuitable for its purpose, should be a dedicated application handling this, rather than a website, just as GNU Info is.


It does have an application. It's called a browser. And the data Wikipedia sends isn't just pure text meant for the user, its also HTML and CSS and Javascript. Most of it is English, which means UTF-8 is a great encoding since it saves bits and can also encode any character

Regardless, browsers will simply declare that they accept compressed data and the server will comply. There's absolutely no reason to worry about this given that the size difference between compressed text encoded as UTF-8 and the same text using any other encoding is statistically insignificant

>I don't understand what you're asking. I like the idea of computing as an English discipline, no different than calligraphy. So, learn English or struggle, as it goes. No amount of translation will permanently solve this ``problem''.


We're talking about your program being able to automagically handle text containing any or even multiple languages, regardless of whatever language is dominant in the scientific community

  No.19464

>>19435
>What a convenient solution. Why not only use Windows and so solve all of the other incompatibilities?

the difference is that there's a reason not to use Windows. There is no reason whatsoever not to use UTF-8.

>Vomiting a file isn't a useful operation, unless you live in a world like UNIX in which most applications are as if baby birds, eagerly holding their maws agape, awaiting for a slurry of bytes that they can process and then dispose of into yet another eager mouth.


this translates to "it's not important to be able to read text files correctly"

>Wikipedia isn't normal text. I can go on and on about my dislike of the representation of text and whatnot in modern systems, but I'll simply say that specialized formatting should be used. Wikipedia, ignoring its flaws which have it being mostly unsuitable for its purpose, should be a dedicated application handling this, rather than a website, just as GNU Info is.


or, alternatively, leave it in HTML where it already works great and is accessable to people(which is the fuarrrking point of wikipedia)

>and UTF-8 was designed on a napkin and is resisted by many areas that don't already use English as one of the primary languages.


dubious, considering that UTF-8 encodes unicode which includes almost every writing system in existence.

>I like the idea of computing as an English discipline, no different than calligraphy.


calligraphy is practiced in almost every language. You're just making yourself look more ignorant.

>I'm disgusted that I use a laptop based on a personal computing standards from the 1980s, emulating hardware from before the 1950s, to run an operating system designed for an old machine in the 1970s.

I'm disgusted with the lot of it and it will collapse under its own weight some day. I would rather love to have my own environment that isn't concerned with any of this garbage, which is something I'm working towards in my spare time.

BUT LISP IS AN OLD LANGUAGE, THAT MEANS ITS BAD!1!!!!!

  No.19468

>>19450
>It does have an application. It's called a browser. And the data Wikipedia sends isn't just pure text meant for the user, its also HTML and CSS and Javascript. Most of it is English, which means UTF-8 is a great encoding since it saves bits and can also encode any character
Modern web browsers are more complex than operating systems. Wikipedia would be better suited to being a real program.

>Regardless, browsers will simply declare that they accept compressed data and the server will comply. There's absolutely no reason to worry about this given that the size difference between compressed text encoded as UTF-8 and the same text using any other encoding is statistically insignificant

One can judge a protocol based on the number of implementations. All of this has such an incredibly high barrier to entry, based on nonsensical decisions made decades ago, and that alone largely discredits it.

>We're talking about your program being able to automagically handle text containing any or even multiple languages, regardless of whatever language is dominant in the scientific community

My solution would be to specify the encoding of a field out-of-band. So, English fields are able to use, say, a six-bit encoding while a Chinese field would use a seventeen-bit encoding and so on. An example of a further optimization would be avoiding the encoding of capital letters in English if the English text only uses capital letters in special instances, such as the beginning of a sentence or initials. This could be further aided by a special entry mechanism that encodes this information and decides between using capital letters or not.

>>19464
dubious, considering that UTF-8 encodes unicode which includes almost every writing system in existence.
The ISO 2022 standard is still in common use.

>calligraphy is practiced in almost every language. You're just making yourself look more ignorant.

I meant that calligraphy is tied to a language, so Chinese calligraphy, as an example, requires knowledge of Chinese and whatnot.

>BUT LISP IS AN OLD LANGUAGE, THAT MEANS ITS BAD!1!!!!!

Keep it quality, in the future.

Now, this textual encoding discussion is rather interesting to me, but I don't want it to consume any more of this thread, so make a new thread for this discussion, if you're so inclined. I may make it myself, but I'll wait at least a day in case someone else wants to.

  No.19475

>>19435
> I like the idea of computing as an English discipline, no different than calligraphy. So, learn English or struggle, as it goes. No amount of translation will permanently solve this ``problem''.
This phrase actually means:
> I greatly enjoy hegemony of English-speaking countries spanning back to XIX century colonialism of British Empire and XX century USA oppression of lesser nations. I also enjoy our exceptional right for inventing computing, as well as status of sans lingua franca of English
I'm so fuсking sick of your ignorance.

  No.19476

>>19475
Calm down lad

  No.19478

>>19475
I'm not a native English speaker myself and I also share the opinion that English is a comfortable language for science and technology.

Having learned most school subjects in my own language, I can tell you it is an inconsistent mess of translations and stupidity. A concept captured by one English word becomes 3-5 in my language plus some short explanation and its somehow still wrong. There simply isn't a way to comfortably express complex technical ideas in my language. It was enough to make me wish I'd learned everything in English from the start.

If you're studying in anything but English, its pretty safe to assume you're being taught second-hand knowledge that's been digested countless times by people with questionable grasp of the English language. Why would anyone want that? The rational thing to is to go straight to the source.

  No.19483

>>19475
There's no place for whining idealists in the modern world. English is set in stone as the de facto language of tech and beyond. I suggest you submit, that way you will enjoy your life more :)

  No.19485

>>19483
I'd be more idealistic myself if only the people who actually bring the knowledge to other languages didn't suck at English.

Here's one cringeworthy example: pulmonary shunt. If there's no air in certain alveoli, blood flow is shunted away because there's no point in sending blood there.

https://en.wikipedia.org/wiki/Pulmonary_shunt

The name itself is enough of a hint. If you know English, you are immediately reminded of a railroad and it helps you understand. It's a simple concept.

You wouldn't believe the contortionisms teachers perform to explain it. They don't know what the fuarrrk the verb `to shunt` means. So pulmonary shunt becomes "the Shunt effect". And then they explain and explain and explain the physiology and draw on the board endlessly and I'm sitting there dumbfounded, unable to comprehend why they're making such a big deal out of this. I look up the English version of this and get it instantly.

  No.19486

>>19485
>>19483
>>19478
>>19475

Let's keep this thread about Lisp and related programming thought, as discussion about the english language and its place in technology and science is barely related to our topics of interest.

  No.19527

>>19366

I just built and delivered a web application (a simple inventory management system) using Common Lisp for the backend and HTML5 for the frontend not too long ago. What do you want to know?

  No.19533


  No.19535

>>19533
>paradox of choice

Unicode really is better than any other alternative. There's not really any choice involved

  No.19537

>>19533
>No.
Please create a thread to talk about UTF and the like, this is a Lisp General and it will stay that way. Stop derailing.

  No.19538

>>19366
I am thinking of writing a web service in scheme.

  No.19539

File: 1477025234078.png (1.18 MB, 200x200, lisp for the web.pdf)

>>19366
here you go, a nice book on CL web programming

  No.19557

Hi everyone, was wondering if someone could tell me what is wrong with my pattern matching:

(defun htmlize (dom-elem)
(pcase dom-elem
(`(,(and (pred symbolp) tag) . the-cdr)
(format "<%s>%s</%s>"
tag
(htmlize the-cdr)
tag))

((pred symbolp)
(symbol-name dom-elem))

((pred numberp)
(number-to-string dom-elem))

((pred stringp) dom-elem)
))

(htmlize '(html (body (p "Hello world!"))))
;; => nil

;; Expected / desired output:
;; => "<html><body><p>Hello world!</p></body></html>"

Obviously something is fishy but I'm basically copying out of a pcase guide I found; the official GNU Elisp manual has terrible documentation on the pcase macro.

  No.19558

>>19557
I believe you need to unquote 'the-cdr' or else it will be looking for your tag symbol, cons'd with the symbol 'the-cdr.
(pcase dom-elem
(`(,(and (pred symbolp) tag) . ,the-cdr)
...))
I don't actually know common lisp but I know racket which has a very similar macro called "match". Does pcase have a "cons" pattern so that you don't have to use quasiquotes? I'd consider
(pcase dom-elem
((cons (and (pred symbolp) tag) the-cdr)
...))
Racket's match has that and also has a nice list splicing mechanism using ellipsis
(match dom-elem
[(list (? symbol? tag) children ...)
(format "<~a>~a<~a>"
tag
(string-join (map htmlize children) "")
tag)])

  No.19577

Hey /lambda/, I'm working on better destructuring for common lisp, so things like key arguments at the start of an argument list can be bound correctly.

(bind exp ((key keyarg1 keyarg2) arg1 arg2 (rest body)) ...)

This makes it possible to use key arguments with macros that have &rest args, without having to use sublists. You can do more with it, like parsing Iterate's english-y syntax, and single key arguments to toggle variables, but that's all I've done with it so far. It's pretty simple, but hopefully someone will find it useful.

  No.19580

>>19557

(defun htmlize (dom-elem)
(pcase dom-elem
(`nil "")
(`(,tag . ,the-rest)
(format "<%s>%s</%s>"
(symbol-name tag)
(htmlize the-rest)
(symbol-name tag)))
((pred symbolp)
(symbol-name dom-elem))
((pred numberp)
(number-to-string dom-elem))
((pred stringp)
dom-elem)))

(htmlize '(html . (body . (p . "Hello World!"))))

"<html><body><p>Hello World!</p></body></html>"

  No.19581

>>19557

Actually I like this better since now you can have nested stuff inside tags.

(defun htmlize (dom-elem)
(pcase dom-elem
(`nil "")
(`(,elem ,rest)
(concat (htmlize elem) (htmlize rest)))
(`(,tag . ,contents)
(format "<%s>%s</%s>"
(symbol-name tag)
(htmlize contents)
(symbol-name tag)))
((pred symbolp)
(symbol-name dom-elem))
((pred numberp)
(number-to-string dom-elem))
((pred stringp)
dom-elem)))

(htmlize '(html . (body . ((p . "Hello World!") (p . ":doot:")))))

"<html><body><p>Hello World!</p><p>:doot:</p></body></html>"

  No.19582

apologies for unformatted code, I am poor man who is horribly uneducated in the ways of /λ/

  No.19584

>>19475
not to the reactionation, but to the idea here:
let's say that violence is a reduction in diversity
applies in all usual use-cases of violence
killing removes from the gene-pool and the meme-pool
colonialism is violent:
part of it is destruction of language
why does destruction of language reduce memetic diversity?
why can't culture be translated?
linguistic relativism? (wikipedia says „concept-paradigm in linguistics and cognitive science that holds that the structure of a language affects its speakers' cognition or world view“)
then there's LISP
it is not a natural language but all the same
clearly opposite of violence: increase in diversity
but it was born in american postwar violence
the environment of LISP's birth is superficial though
I think the thoughts LISP permits are a greater increase in diversity than its promotion of language homogeneity

  No.19614

>>19557

So the code in >>19558 works, but only if the function is called as such:

(htmlize '(html . (body . (p . "Hello world!"))))

Sort of like in this post: >>19581

Why is this, though? I thought in almost all Lisps lists were implemented as nested cons. Indeed, this little snippet seems to support that claim:

(equal '(a b c) (cons 'a (cons 'b (cons 'c '()))))
;; => t

So, why can the pcase not match a list written normally as a list? Is there a difference between the list and cons functions?

Also, assuming they are not at all the same thing, how do I use pcase to get the car of a list of arbitrary size and not just a cons pair?

  No.19802

so I was messing with CL, using Quickproject to create a project.
It's such a fuarrrking pain in the ass to find a simple tutorial with all the steps like, how to create a project, how do you build it when you change something, etc

  No.19803

>>19802
Are you going to write one when you figure it out?

  No.19808

>>19802
It's a lot easier (for me at least) just to (ql:quickload ...) in the top of a file, create a package, and then load the file from the command line or Slime. If the project gets large enough, I add the .asd file and remove the ql:quickload.

(proclaim '(optimize (speed 0) (safety 3) (debug 3)))

(ql:quickload '(alexandria iterate anaphora) :silent t)

(defpackage my-package
(:use cl iterate anaphora alexandria))

(in-package my-package)

  No.19809

>>19803
I don't have a blog or something to publish it

>>19808
well if we have quicklisp I'd rather use it than asdf directly
>(in-package my-package)
this is where took me some 10 minutes to find out, maybe because the answer is more related to packages than with quicklisp and I was looking in the wrong place

I noticed this guy uses that and then it worked for me:
https://www.youtube.com/watch?v=SPgjgybGb5o

  No.19836

Playing with kawa scheme and wrote this monster.
(define-macro (xx . lst)
(let ((ret '()))
(let loop ((l lst) (pre ""))
(when (not (null? l))
(let ((tmp (car l))
(tmp2 (if (pair? (cdr l))
(cadr l)
'())))
(cond ((null? tmp))
((null? tmp2)
(if (pair? tmp)
(loop tmp pre)))
((and (not (pair? tmp))
(not (pair? tmp2)))
(set! ret
(cons
(list
tmp2
(string->symbol
(string-append pre (symbol->string tmp))))
ret)))
((and (not (pair? tmp))
(pair? tmp2))
(loop tmp2 (string-append pre (symbol->string tmp)))
(loop (cddr l) (string-append pre (symbol->string tmp))))
(#t
(loop tmp pre)
(loop (cdr l) pre))))))
(display ret)
`(display "")))
;; testing it 
(xx
(java.
(lang.
(Integer ji)
(Byte jb))
(test.
(Test1 jt1)
(Test2 jt2)))
(sec.
(test.
(Test1 sec1)
(Test2 sec2))))
;; displays
((sec2 sec.test.Test2) (sec1 sec.test.Test1) (jt2 java.test.Test2)
(jt1 java.test.Test1) (jb java.lang.Byte) (ji java.lang.Integer))

Basically it walks the tree and concatenates symbols until it gets to pair (x y) and then it pushes it to return list.
How would you do this with define-syntax?

  No.19849

Which are your most used libraries in Common Lisp, for those who have an idea.

  No.19852

>>19849
cl-ppcre
alexandria
asdf
uiop
clack

  No.19853

>>19836
Blimey.
I don't think sytax-rules is actually capable expressing this macro. But I usually use imperative macros anyways. Go read up about your scheme of choice's imperative hygienic macro system (if it has one).

The three most common are er/ir macros (chicken), sc macros (chibi, mit), and syntax-case (r6rs, guile, racket). er/ir is the simplest, but er isn't hygienic bg default, so it's little better than defmacros, and ir is O(n) for your input and expansion size. sc is pretty nice, IMHO, and syntax-case is really really overcomplicated (only my opinion).

  No.19858

>>19614
>So, why can the pcase not match a list written normally as a list? Is there a difference between the list and cons functions?
It _can_ match lists as lists. The only problem is that
`(a . b)
is the same as
(cons 'a 'b)
Meaning that pcase is match your list against the symbol 'a and the symbol 'b, its not matching a & b as variables.

  No.19860

>>19836
>concatenates symbols
Can't do that with syntax-rules. define-syntax isn't really what defines how the macro system works, it's supposed to just bind identifiers to macros at compile time. It's like saying define when you mean lambda.
Anyway you can't concatenate symbols with syntax-rules. Although it is turing-complete, it doesn't have "interface" to most language features. It can do any kind of data structure manipulation as long as the data structure is a cons or vector, and can test equality on strings, symbols, numbers, and lists and vectors of those types. You can't do I/O, math*, string manipulation, string to symbol conversion or symbol to string conversion, nor arbitrary Scheme functions (obviously). This is sufficient for many macros, including anaphoric macros (though they are difficult to write unless one knows how to write CPS macros).

*math with numbers. You can represent natural numbers easily as lists where the size of the list is the number; mathematical operations are easy to express with tail recursive macros so nothing special is needed (like CPS macros). I've done this to implement a compile time game of life implementation.

  No.19865

>>19849

split-sequence

I'm amused by how often I reach out for this tiny little useful library (mostly for string manipulation).

  No.19867

>>19849
cl-ppcre
iterate
flexi-streams
cl-json
dexador

Lambdalite is pretty sweet if you just need a quick and dirty DB.

  No.19886

Has anyone used either Lucerne or Caveman?
What's your opinion on them?

  No.19919


  No.19977

File: 1478364617403.png (28.14 KB, 200x62, l.png)


  No.19986

>>19977
What's hard about this? Just do a normal sets in a hash table method (or hash tables in hash tables if you want to associate weights). I don't even think I'd bother building a separate library if I needed to do that. It's certainly good enough for A*.

  No.20008

>>19986
let him write it. he doesn't like cl-graph because reasons, then someone suggested an alternative which is not good because it uses GPL as license.

  No.20028

File: 1478476456184.png (33.47 KB, 200x90, l.png)

>>20008
and he's done it

  No.20037

is anyone experiencing this bug in Spacemacs? Things are sent to the REPL without me pressing enter and get evaluated, and obviously since it sends invalid expression I get an error, the debugger pops up and it's very disruptive.
see the video at https://dl3.volafile.io/get/m0EVPzAHw668VQ/bug.mp4

  No.20046

>>20028
The absolute madman!

  No.20171

>>18531
I am a Emacs user, but
>>18547
is very true.

You have to start using Emacs for __everything__ to be really productive; i.e. compiling, running, etc. It can do it (wonderfully) but if you already have a workflow established with another editor, you will have to configure Emacs to do all the things you usually would do. It really is an environment, not only a text editor. The powerful thing is the whole environment is built around editing text, so you have a more interactive text environment. I respect other's choices in editors, but I like Emacs because of that. Your mileage may very.

  No.20195

What are the best options for logic programming in a Lisp?

miniKanren? core.io in Clojure?

I just want to learn, no need for production-quality code, but that'll be a plus if I want to include it in my portfolio or something

  No.20196

>>18547
>I also don't like using emacs so much because I live in the command line
Run "emacs -nw" in the shell or use emacs-nox.

  No.20201

>>20195
miniKanren is an embeddable logic interpreter. If you want to learn, read The Reasoned Schemer which uses it.

http://minikanren.org/#implementations
shows a list of host languages.

Choose the host language you're most familiar with, if you aren't familiar with any of them I'd recommend Scheme and Racket since they take the least effort to get up and running, require the least amount of mental overhead, and have canonical implementations of miniKanren written by its main author W.E. Byrd.

  No.20202

There is another Lisp Game Jam, anyone going to participate?
https://itch.io/jam/autumn-2016-lisp-game-jam

  No.20203

>>20201
Familiar with scheme, CL/clos, and only a tiny bit of clojure.

Going to go with scheme + miniKanren w/ the Reasoned Schemer.

Thanks!

  No.20215

File: 1479239538402-0.png (152.14 KB, 200x200, logic-programming-in-scheme.pdf)

File: 1479239538402-1.png (270.09 KB, 200x200, MuKanren2013.pdf)


  No.20216

File: 1479239668453.png (17.45 MB, 200x200, Peter Norvig-Paradigms of artificial intelligence programming_ case studies in Common Lisp-Morgan Kaufmann (1991).pdf)

>>20195
PAIP guides you through writing your own prolog interpreter or compiler, I can't remember which one

  No.20222

>>20202
I've been fuarrrking about with clojure and have made some form of map generator thing, so i might, the only problem is i dont know lisp/clojure particularly well.

  No.20240

>>20222
then this seems like a good way of improving since the competition will keep you more motivated than some side project you'll drop half way

  No.20254


  No.20255

>>20254
An anonymous person wrote it.

I've been meaning to replace it with my own explanation, along with improving the other texts. I'll try doing that within the next few days.

  No.20257

>>20255
He confused the concept behind cons with a implementation of that concept. what he (poorly) explained here is how the data structure know as linked list can be used to implement the abstract type list. cons is not even about lists at first since it's for constructing pairs. A list in lisp is an implicit type made of nested pairs where the final cdr value is null (like strings in C are an implicit type where a char array is terminated with the null char).

cons should be first explained with procedural abstraction through lambda calculus, using lisp notation or not.

(define (cons a b)
(λ (selector) (selector a b)))

(define (car pair-function)
(pair-function (λ (x y) x)))

(define (cdr pair-function)
(pair-function (λ (x y) y)))

  No.20258

going to give the little schemer a go. I have zero programming experience, any other book I should start with (probably too dumb for SICP since my math is lacking)

  No.20264

>>20258
The Little Schemer is a good starting text if you want to learn functional languages like Lisps. I suggest supplementing it with the first 3 or so chapters of the Scheme Programming Language: http://scheme.com/tspl4/
along with any other chapters you find interesting. Read your programming language's documentation. If it's like Racket and has a guide, read that guide. Racket's is great.

If you don't have a preference for text editor use DrRacket (which comes with Racket). You should learn Emacs eventually but focus just on programming for starting.

  No.20265

Does Common Lisp have any easy way to parse floats/doubles from a string? It seems to have parse-integer, but no equivalent for the others.

  No.20266

>>20265
http://cl-cookbook.sourceforge.net/strings.html#number
> PARSE-INTEGER doesn't understand radix specifiers like #X, nor is there a built-in function to parse other numeric types. You could use READ-FROM-STRING in this case, but be aware that the full reader is in effect if you're using this function.
See the page for examples.

  No.20267

>>20266
Alright, I'll look into that.

Having a local copy of the hyperspec is really handy.

  No.20272

Wow, just learned that R7RS Scheme has applicative data structures and (most exciting for me) generic iteration! No more hash-map, (vector-ref #(...) 1), map, for-each, and other built-in typically list-only are now generic and work for all sequences, and instead of calling a separate -ref function for each sort of data structure, you can just "apply" it to the index element you want.
(display (#(1 2 3) 1))
> 2
(define h (hash-table* 'a 1 'b 2))
(display (h 'a))
> 1
How cool is that? I've been using these features in Racket Lisp, but seeing them in the Scheme standard is very exciting. Apparently some of the new features were initially introduced for R6RS. Scheme's looking to shape up to be a really good language, and I'm glad it's still feeling like it's advancing and staying modern. I guess the emphasis on keeping the language small and "tight" (for lack of a better term) allows them to ditch a lot of cruft that normally accumulates in these standards.

Anyway, where I found this out: http://carloscarrasco.com/a-love-letter-to-s7-scheme.html

  No.20273

>>20266
>>20267
Ah, finally got to try it out. That does work.

How come it's not a separate function though?

  No.20275

>>20272
Are you sure that's R7RS? This looks like a post about S7, a Scheme implementation which says it's "compatible" with R5RS and R7RS despite not having syntax-rules.

  No.20277

>>20272
They're not in the R7RS, only in s7. The features listed in that post are really neat but they seem to add some sort of "magic" to the language, magic that you can't access.

  No.20283

>>20272
Some of that was implemented in R6RS (I know that computed values, aka function variables, were), but they were withdrawn from R7RS (and for good reason: computed values mean that there are even less invariants for macro writers)

The hash table and vector syntax is trivial to implement in Scheme. Here's an implementation in CHICKEN (as of yet untested: I don't have a repl on me), which should work on any Scheme with srfi-17

(define (vector* . args)
(let ((vec (apply vector args)))
(define (vecacc . args)
(cond
((= (length args) 1)
(vector-ref vec (car args)))
((= (length args) 2)
(vector-set! vec (car args) (cadr args)))
((null? args) vec)
(else #f)))
(getter-with-setter vecacc vecacc)))

Implementing read syntax, which is highly implementation-specific, and inplementing a hashtable version of this function are both excercises left to the reader, although it shouldn't be too hard.

  No.20284

>>20277
>>20275
Oh, my bad, got a little bit too excited about a feature I enjoy using.

  No.20307

>>20272
>How cool is that? I've been using these features in Racket Lisp
Which package are they in? I've been looking for something similar but found nothing.

  No.20308

Best solution for key and multiple value storage? Need reliabilty, on-disk, simplicity, performance.
Key is a string, and I want to store 2 numbers for each key. Candidates:
>Using filesystem: folder key, 2 files with number
>hash table and cons/plist, writing out to single file (inefficient)
>redis, gdbm, etc

  No.20309

>>20308
I would strongly consider using a hash table with customized file writing procedures for efficiency, rather than serializing the hash table normally.

This solution is relatively simple and avoids dependencies on nonstandard features.

  No.20310

>>20307
#lang Rackjure adds applicative syntax via #%app, standard library for forms which can iterate over all sequence-types, and sequence-operation functions. sequence-map sequence-andmap etc. Rackjure's applicative allow you to use a dictionary as a function when it's in the first position, and dictionary is a generic that covers hash-tables, vectors, assocs, and lists.

  No.20315

>>20308
Whats the expected size of that datastructure?
Will it be mostly read once in place, or will read/writes be more balanced?

Both can have an influence on what structure to pick, or if an external DB might make more sense.

  No.20316

>>20315
On my phone so I don't have the code. It's an IRC bot for the Lainchan radio with !choon or !poon if the current song sounds good or bad like CS:S radio bots. I get the title out of the radio using http://lainchan.org:8000/status-json.xsl and I want to store choons and poons as int for each song.

  No.20333

Anyone tried Hy Lang ? It's pretty cool.

  No.20334

>>20333
Only a tiny bit, its quite nice. It helped me in learning python very quickly because i knew some lisp so the python output was quite nice.

  No.20335

>>20334
Did you realize any project with it?

  No.20336

Is there any equivalent of Python's requests library?

  No.20337

>>20336
I've no idea what that does, but I'd guess Drakma is:
http://www.weitz.de/drakma/

It's nice that the library is largely one function. It has one of the longer lambda lists one usually sees.

  No.20340

>>20337

Yeah, Drakma is Common Lisp equivalent of Python's requests library.

I just use Drakma to implement web scraping application just a few days ago, and it works like a charm.

  No.20344

>>20337
>>20340
ok, thank you

  No.20347

How do you guys learn how to do stuff like create a website, put something running on AWS, etc?
Did you already know how to do it in other language and therefore the transition for doing that stuff in CL was easier and it was just a question of looking through the docs?
Because from what I've seen, documentation and guides for Lisp are quite rare, there might be an API reference of the libraries in Quickdocs but that's that. No tutorials or guides with examples of how to use the libraries.

  No.20352

>>20333
Yeah, I used used it once because I was trying to rewrite an oversized mess of Python and didn't want to touch FIOC directly; I ended up rewriting it from scratch in Hy, the original code was just that awful. It's not bad, but the python part just makes awkward.

>>20347
You should probably do it in another language first. When I still didn't know how to write a website and tried looking into the Racket library to do it I didn't understand any of it, even though it had good documentation and a lot of examples. It still assumed you had previous knowledge of how a server program works.
I learned it using Ruby. It's a nice and dynamic language and with its metaprogramming parts it doesn't make you miss Lisp too much.
Otherwise there's a Guile Scheme library called Artanis, inspired by Ruby's Sinatra.

  No.20356

>>20347
>How do you guys learn how to do stuff like create a website, put something running on AWS, etc?
The WWW is a mess, so I wouldn't call myself learned. I simply write Lisp programs to output HTML, if I need to.
For something like AWS, I would like to think it would have decent documentation, but probably not.
>Did you already know how to do it in other language and therefore the transition for doing that stuff in CL was easier and it was just a question of looking through the docs?
I don't really think of any language in particular when doing something, in that way.
I'll think about how to implement something with Lisp and other languages and weigh the pros and cons, so there's no transition.
>Because from what I've seen, documentation and guides for Lisp are quite rare, there might be an API reference of the libraries in Quickdocs but that's that. No tutorials or guides with examples of how to use the libraries.
As a rule, I try to avoid libraries, unless I wrote them.
The libraries that are documented are generally good and eventually they become dominant. Look at an Edi Weitz library as an example.

  No.20357

Hi, first time ever posting on lainchan in fact but I'm kind of a noob.

Comoing from C and python being the only thing ive written few programs in how do i start with lisp? I mean, if I were to run it, all i know is in C and python and if i wrote (+ 2 2) in vim(because I dont have emacs,at least yet) what do I do with it. How do I save it, do I complie it. Just wondering

  No.20360

>>20357
>Hi, first time ever posting on lainchan in fact but I'm kind of a noob.
Hello.

>Comoing from C and python being the only thing ive written few programs in how do i start with lisp? I mean, if I were to run it, all i know is in C and python and if i wrote (+ 2 2) in vim(because I dont have emacs,at least yet) what do I do with it.

Lisp environments have an REPL, similarly to how Python does. You'll probably find it easiest to start with Emacs Lisp, as it has an introduction and extensive reference manual.

Remember to check the texts; you can find the links for the Emacs documentation here as well:
https://lainchan.org/~lisp/

I'll start you off by pointing you to this:
- An Introduction to Programming in Emacs Lisp | https://www.gnu.org/software/emacs/manual/eintr.html

>How do I save it, do I complie it. Just wondering

Lisp programs are typically saved to files, as most other programs are.
Compilation in the sense you mean it is usually accomplished by saving the entire environment for later.

  No.20369

>>18670
If possible, get over your hate of emacs.
It is useful, though not necessary, for lisp development, but also for so much more.

Once you are over the learning curve there is simply no other editor that enables you to be this productive as emacs.

  No.20370

>>18693
ok, ecl does not work, All links to the package are dead, and there is no ecl package on termux (yet)

  No.20373

>>20360
So helpful, thanks a bunch

  No.20376

is there any workaround for this http://www.xach.com/sbcl/doc/idiosyncrasies.html ?
I have a defconstant in my code every time I try to recompile the code I get an error saying I'm redefining a constant, which I'm not, I haven't even touched it.
Should I avoid defconstants?

  No.20377

>>20376
found my own answer, I went with alexandria:define-constant
thanks anyway

  No.20389

File: 1479980301893-0.png (229.6 KB, 152x200, 4333926_p0.jpg)

File: 1479980301893-1.png (377.03 KB, 200x134, raccoon.jpg)

Even though it isn't an anniversary or anything, I was feeling a little nostalgic about these threads and learning how to Lisp in them today. I remember the first thread, when I thought OP was genuinely trolling /g/ asking questions like "why do you think Lisp is a superior language?" or otherwise insinuating that Lisp was the best. However, I decided to treat the thread seriously because I wanted a place to (calmly) talk about Lisp and share Lisp code. In light of how much of a soykafstorm DPTs were then it wasn't surprising we got some bad threads, so I'm very glad we're here now even (especially?) if it means we have less newcomers. Regardless of where we were, it was always fun talking about and comparing Lisps. So thanks to everyone who's spent time in these threads, they mean a lot to me.

So I actually contribute something Lisp-related, here's a command line image viewer I hacked together for this thread in Racket. You can change the "resolution" however you want by parameterizing console-cell-width and console-cell-height, but generally stay around 11:19 for the width to height ratio so the aspect ratio doesn't get goofed. (Well, 11:19 for my font at least... I'm not sure how fixed width font dimensions work!) It also normalizes its input so it always has at least one cell that's the darkest and one that's the lightest, for a little bit more clarity. It's nothing amazing and is probably "the naive solution"; I think some image processing tools can speed it up significantly but I wanted something simple to make that worked. It's pretty slow, and averages regions of pixels for brightness so it speed isn't increased when you decrease the resolution size.

Depending on your browser window size/screen resolution/font size, you'll have to zoom out to see these right.

Here's the attached art of Mugi:
http://sprunge.us/TdBa

And finally the photograph, which turned out poorly (unsurprisingly):
http://sprunge.us/OEVL
You can see the rings on the raccoon's tail though. (The raccoon in the picture is okay, just sleeping.)

Unfortunately, it had a very hard time rendering SICP's cover. Worthless!
Here it is: http://sprunge.us/URdi
Nothing I'm too proud of, it was just an exercise to get something working quick.

  No.20400

Can anyone recommend me some nice plotting/graph library for common lisp(sbcl)?

  No.20404

Which is the most popular dialect of Lisp amongst lainons?

  No.20407

>>20404 Hard to say. CL is pretty popular. Then Racket and then the Schemes. And no, Racket's not a Scheme.

Between the Schemes, Chicken seems to be the most popular. It's also my favorite, so I may be biased.

  No.20408

>>20407
Guile isn't that popular here then? Thought it might be. I'm new, and I'm curious what lainons think of Guile.

  No.20418

>>20408
I mostly use Guile. I think it has a nice small community and there is a lot of activity going on lately with Guix and the next version of Guile. It never did live up to the initial plan of being the extension language for GNU software.

  No.20424

>>20408
Guile is a very nice Scheme. No idea how popular it is here, though. I haven't seen it mentioned as much as the others.

But yeah, Guile is nice. It's got some cool features (it's one of the few schemes with native thread support, for one), and while it's not as easy as CHICKEN or Gambit, you can bind to C with relative ease.

There are less libraries for Guile than there are for CHICKEN, but most of the big stuff is there. Also, the average API quality in libraries is significantly higher (for example, compare guile-ncurses to the CHICKEN ncurses egg).

  No.20442

guile is the worst scheme implementation by far.

slow
bloat (compare the required dependencies with chicken or gambit or racket)
incomplete
GNU

it does look like a random scheme implementation from the 80's for the programming techniques of the past.

  No.20458

>>20408
The last time I used Guile, I had a great time calling C code from it, but when I tried to write some networking code, I started to get really annoyed. Scheme is dynamically typed, but because there's usually some kind of object or record system built in it's usually not a hassle. The records in the Guile networking library are represented by arrays with no type checking. I had a bug where I was passing the wrong object to a function. This was extremely hard to debug because the accessor functions were just wrappers over array indexing, so I could call accessors on the wrong objects and still get a value back. The type system was actually worse than C. It was like writing code in Python, but instead of attribute errors raising exceptions they just silently gave an incorrect value.

  No.20464

>>20458

Wow. That is actually awful. Like, really, really bad. How the hell did someone come up with that, and how the fuarrrk did they think it was a good idea?

  No.20467

>>20458
Racket is a little big, and not extraordinarily fast, but as far as I can tell it does everything else right... it has a good C FFI (has some constructs for common C features, e.g. C structs, return codes, multi-value returns using out pointers), straightforward implementation of structs, extremely easy threading, support for exception throwing & handling.
I'm not sure if it's any good for embedding into C applications, but so far it's been pretty awesome on its own, in my experience.

  No.20482

>>20467
Racket has way too much complexity in core, IMHO. It's not actually badly designed, but it's irritatingly large. In CHICKEN, and other more minimalist Schemes, you can hold most of the language in your head, which means that you know exactly what tools you have available.

  No.20485

>>20340
do you have a link to the code you could share please?

  No.20489

>>20482
It's true that it's pretty big, but after some time I've come to appreciate just having hash tables, bytes, etc. After using other languages which are large (e.g. Haskell) I've come around on this one. Racket is at its core simple, its best features are sometimes just large macro systems (something it is very good at!). For example, syntax-parse compiles to simpler forms completely. I think Racket's really neat, especially its language building framework. (And ESPECIALLY how languages are truly just macros too, that compile to #lang racket!)

I only say this because I agreed at one point. I still think it's a valid viewpoint, sometimes I like working in Chicken because it's small and compiling to C is neat (not to mention its extremely cool use of Cheney on the M.T.A., something all Lispers should appreciate at some point or another)! I like all Schemes, and in my view it's an extended Scheme. In many ways it's not (not even mutable cons!) but I feel like its design is something that's "Schemey". To me the "idea" of Scheme is that it allows for complex features from a simple and small core. Racket's core truly is small, but unlike an implementation of that core, it features various large extensions. (This is true to an extent with all Schemes but that's beside the point)

  No.20493

>>20442
Sorry, but Guile is one of the best and the upcoming Guile 2.2 is quite fast.

  No.20503

File: 1480284189104-0.png (216.53 KB, 172x200, 1475696503082.jpg)

Since it's Lisp general, I suppose there's enough profiecient Lisp programmers.
What does Lisp do better than other languages?
When should I consider using Lisp?

  No.20511

>>20503
Lisp does especially well when you need to write complex programs with poor specifications and unclear futures. Anytime you need to be able to quickly create a robust solution, Lisp is your guy.

  No.20589

tried to program c with lisp using ecl
there is / were? some kind of bugs with ecl and cffi and somethings wouldn't work
changed from ecl to bigloo, too bad bigloo's irc channel is dead
now the new ecl maintainer is doing some nice work with ecl
I don't know what to use anymore.

  No.20604

does anyone have a problem with the lack of types in Common Lisp?
In languages like java when I call a function or a method the IDE will tell me the type of whatever is returned so it's pretty easy to know which other method should I use that receives as argument a matching type.
How do you do that in CL? Specially when the documentation isn't that good

  No.20614

File: 1480670204287.png (842.4 KB, 200x125, trimmed.webm)

Writing a Lisp editor! This is a fun idea I've had for awhile. The video explains it better than words could.

Each block of output is formatted like so, line by line (except for the first which has no character input):
The character I just typed
Possibly a prompt like "symbol> " and my typed input
The "path" to the focused area
The current sexp that's being edited. The red region is the focused area

When I finish I probably won't show anything except the prompts and the sexp, so this is just for clarity.

It's in Racket and was written in a hurry tonight. I want to change the code a lot (some features like macros and undo history, architecture, and I kinda want to rewrite it using test driven development because I'm a masochist) before I show it but for now this works.

I also want to add some built in, language specific macros too (like one that creates a function definition and puts you at editing the name of the function, etc). Then it'd be fun to implement my editor for different languages like Clojure or CL! The biggest problem I'm going to run into is that I'm rolling my own printer so I can do the terminal color stuff, and for actual programs pretty printing will be needed. I've implemented a Lisp pretty printer before but I remember it being pretty messy to do.

Realistically it probably won't be effective for actual editing. Right now I have to do a lot of thinking to use it (as you can tell in the video) which I think is a good sign that it could be fast enough to be effective.

  No.20615

>>20614
Something I realize might not be obvious from the video:
if you try to move somewhere within an object that doesn't exist yet, it tries to make what you're doing work in an intelligent way. For example, > and < move to the next and previous sexp in the list you're currently in. If there is no next sexp, it makes one and focuses you on it. < will work the same way but it's actually a little harder to implement so right now it just crashes when you use it at the head of a list, lol. (Speaking of crashes, I really need to wrap the main loop in an exception handler so I don't have to blindly type stty sane<enter> whenever this program breaks.) I also use a (for "car", d is for "cdr") like this a lot in the demo.

  No.20617

>>20503
>What does Lisp do better than other languages?
Lisp's homoiconicity, metaprogramming, number system, and garbage collection are all laudable, especially relative to other languages.
Lisp is one of the better languages with regard to allowing one to avoid paying focus towards what they want to ignore.
>When should I consider using Lisp?
Use Lisp when a suitable dedicated language doesn't already exist.
Don't use Lisp for writing pretty documents, as TeX already exists. Don't use Lisp for calculations involving detailed array work, as APL does that far better.
When complete or almost complete control over the computer is needed, use the machine code (a Forth may also work here, varying).

I use Lisp when I need arbitrary precision arithmetic, want to experiment, or simply don't want to manually manage memory and whatnot, among other uses. As an example, I may write an assembler in Lisp so I don't need to deal with memory issues while experimenting with ideas and then later implement it in a language with a smaller footprint.

It may seem that Lisp does things other languages also do, which is true, but Lisp usually does them better. Lisp garbage collection and compilation typically far exceed other dynamic languages, to name two qualities.

>>20589
SBCL generally gets the most attention with such interfaces.

>>20604
>does anyone have a problem with the lack of types in Common Lisp?
Most of the languages I prefer don't have many types, if any, so no.

>In languages like java when I call a function or a method the IDE will tell me the type of whatever is returned so it's pretty easy to know which other method should I use that receives as argument a matching type.

>How do you do that in CL? Specially when the documentation isn't that good
Are you using the development functions, such as INSPECT and DESCRIBE? An implementation such as SBCL will generally include type information in the output.
If you must discover this for yourself, read the implementation until you hit a ``type bedrock''; by that, I mean resolving types until you reach functions that are strictly typed, such as + and CAR, to discover the greater type.

>>20614
Is this video file damaged? I'm unable to play it.

  No.20618

File: 1480700808474.png (70.84 KB, 51x200, mpv-shot0001.jpg)

>>20617
>Is this video file damaged? I'm unable to play it.
Sorry! It works on my machine so I can't really tell you what's wrong.

Here's an actual description:

Basically it's a Lisp editor that starts you off with a sexp (specifically ()). The sexp is "focused", meaning traversal commands work relative to it and changing commands replace it with something. You can traverse (i.e., move the focused sub-sexp) using some keybindings. For example, if the sexp is a pair, "a" focuses on the car and "d" focuses on the cdr. If the sexp is not a pair, the program "makes it one": if the user asked for the car, the formerly focused sexp becomes the cdr of a new pair with () focused as the car of that pair. There are more complex traversal commands, like ">" for "next", which also work like this, allowing for easily creating lists.

The changing commands are pretty straightforward: s prompts for a symbol, n for a number, " for a string. For symbols and numbers, any whitespace terminates the prompt, strings are terminated by another " (I suppose eventually I should add escaping, haha).

Right now the UI is a hacked together CLI, but I wrote it with alternate/multiple UIs in mind. Right now the biggest issue imo is a lack of pretty printing but I'm too lazy to tackle that for now. Since I posted I also implemented stacked "buffers", each one sexp in size, and file writing (no reading yet, lol. This is just a toy anyway).

I have to say after playing with it more I've gotten quite a bit better! I'll try to figure out what's going on with my screen capturing before I try again. Here's a screenshot of the video I posted, you can read my first post to figure out what's going on (the last line of each block is the sexp, the focused sub-sexp is red).

  No.20627

Hi /lam/, I've been working on some toplevel syntax extensions for CL, as well as a lisp graphical platform using xlib, cairo, and pango.

(mapcar (x y -> (+ x y)) '(1 2 3) '(4 5 6)) => (5 7 9)

(reduce #'max list :key (gethash <> table))

(if (> 6 (value <- (gethash key table)))
(print value)
(error "whoops"))

  No.20641

Does anyone here emulates Symbolics Genera?

  No.20673


  No.20680

So in the last thread, while it was already saging, I announced that maybe I would get on board a startup to build a huge data analytics project in Africa using Common Lisp. For Agriculture mostly.

Well, on Saturday I met with my futur boss and colleagues, and I got CL greenlit as the main programming language for this project.
I argued that it would not only enable us to (out)compete possible other players in this field, but also that we would be able to keep everything open source while not fearing that our code would be copied immediately (since fluent CL is not that widespread).

So if everything goes right, starting in January I may become the CTO of a potentially huge, 100% CL (except for the cryptolibs), big data project. And since he is connected to all kinds of NGOs as well as the world development forum and world bank, on top of his economy-phd, its 98% sure that everything will go right.

I could just explode with joy right now.

  No.20685

wtf this thread too is alrady saging? thought saging started at 300 posts.

  No.20687

I was trying the library iterate and tried to run one of the examples after loading with quicklisp
I tried:
(iterate (for el in num-list)
(when (> el 3)
(collect el)))

and it didn't work. I had to rewrite it as
(iterate:iterate (iterate:for el iterate:in '(1 2 3 4))
(when (> el 1)
(iterate:collect el)))

is there a way for not having to use the package prefix all the time, or at least using a shorter alias like it?

  No.20688

>>20687
disregard the "num-list", I used '(1 2 3 4) as in the other example. I just copied it from the website

  No.20689

>>20680
That's great news. Do keep us updated on this.

>>20685
You've reminded me of this. It's been corrected. The new bumping reply limit for /λ/ is the same as the reply limit, three hundred.

>>20687
>>20688
Use USE-PACKAGE and learn of DEFPACKAGE.

>>18550
>>18634
As an acknowledgement, the libraries I've mentioned writing in these posts obviously haven't been released yet. I've been rather pre-occupied, but I've made some progress towards the work on these. My goal was to attempt to have them in a releasable state before this thread ended.

  No.20690

>>20689
>Use USE-PACKAGE
thank you, that worked

  No.20691

File: 1481063983788.png (996.19 KB, 200x143, lam-repl.png)

Update on the CL graphical library/environment thing, managed to get a repl working! Very simple emacs-like key bindings for now, still working on mouse support and scrolling.

  No.20693

>>20691
>CL graphical library/environment thing

More details please.

  No.20694

>>20693
It's sort of a hybrid project, started a bit ago by me and another lainon. It's an application/interface library, made with cairo and pango, but the goal is to provide a complete environment for CL development and applications, very similar to how opengenera runs on linux, but as a session manager. The applications can run by themselves as well, in a normal WM, to help testing and adoption.

Currently, it's just the repl, and the code isn't general at all, we're trying to get drawing and event handling down before creating a layer of abstraction.

main repo:

https://github.com/Arboreta/arboreta-core

  No.20695

File: 1481093011001.png (282.97 KB, 200x200, _.png)

>>20680
Nice. For me, I'm currently writing a Python REST api in a parttime job for a research institute which I would personally like to program in Common Lisp instead. It's a simple project so I might rewrite the whole thing to compare the differences. Although if I show it to them, it will only be with a very soft suggestion for replacement. Common Lisp is not necessarily the best choice because it's important to consider the circumstances when I'm gone.

  No.20698

>>20680
> data analytics project in Africa
>Agriculture
>connected to all kinds of NGOs as well as the world development forum and world bank
illuminati pls go

  No.20699

Does anyone know of any cracks for Lispworks or Allegro?

  No.20701

I want to get myself a book for the holidays. Is there something that you'd recommend me to get for learning sbcl, or just common lisp in general?

  No.20702

>>20699
No.1) Why would crack developers focus their efforts on a proprietary environment shipped for an obscure language? 2) Why would you want to pirate something like that? There are already free implementations and environments for Common Lisp that you could use, so there's no excuse for pirating one. I mean, it's not like Lisp work is known for its great paychecks to begin with so why would you want to hurt those developers by pirating their software? They even offer trial periods, hobbyist/student/personal packages, and negotiate on prices if you call or email them.

  No.20704

>>20698
Its actually Templar sponsored, thank you very much!
Like we would allow those filthy illuminaty to sully our hallowed halls.

  No.20705

>>20695
>because it's important to consider the circumstances when I'm gone.
they'll have to hire a fellow CL programmer. I don't see a problem

  No.20707

>>20705
This, if it were my decision, I'd make projects in CL to make more space in the market for CL programmers.

  No.20708

>>20705
It's a tiny center with a scant number of employees under the research institute. Funding for the project comes from a grant and the job description wishes for Python. The most complicated parts will just be accessing binary files and making basic reductions. The level of difficulty and pay is a small internship geared for undergrad/grad students. Python fits the problem domain and is understood by a number of the existing staff. The written code will be high quality and will include extensive documentation regardless of the language.

From the perspective of the employer, there's not much incentive to switch if I make the case. Though at the very least, I can leave a copy of the Common Lisp version on the server as an artifact for the years (decades?) to come.

  No.20711

is there a good tutorial on debugging in CL? And how to use slime to debug stuff?

  No.20712

>>20694
Interesting project, but why try to make an IDE that will never be able to compete with emacs?

  No.20713

>>20711
http://malisper.me/category/debugging-common-lisp/

This should be complete and practical five part guide that covers debugging in Common Lisp. Apply yourself lainon, the first and second part is found on the first page of Googling 'debug Common Lisp'.

  No.20716

>>20694
good stuff man

  No.20780

>>20694
The repl looks nice so far, and scrolling is smooth as fuarrrk.
I'm definitely interested.

  No.20786

Hello lainons,
It's time for me to step up my game and learn CLOS. What are the recommended resources for that?

  No.20787

File: 1481747011394-0.png (1.77 MB, x, [Sonya_E._Keene]_Object-Oriented_Programming_in_Co(BookZZ.org).djvu)

File: 1481747011394-1.png (19.25 MB, 200x200, (MIT Press Classics) Andreas Paepcke-Object-Oriented Programming_ The CLOS Perspective-The MIT Press (1993).pdf)


  No.20806

>>20787
Thanks for the material!

  No.20810

File: 1481826363714.png (11.44 MB, 200x200, [Gregor_Kiczales,_Jim_des_Rivieres,_Daniel_G._Bobr(BookZZ.org).pdf)

>>20806
You're welcome. Here have this one too, it's not really about CLOS but about the MOP, which CLOS is based on.

  No.20825

>>20810
I will look into it too, thanks again!

I spent some time on the first book today, and the introduction is very well written. So far the information density was high, which is great in my opinion. I feel like I got a grasp of the basics, but the book is so interesting I'll keep reading.

  No.20896

Am I correct in thinking that #'read only reads in data, and doesn't do any execution?

Is it safe to say, store "(a b c d)" or "foobar" as a text element in a database, and retrieve this data using #'read on the client side? If I understand right, a user somehow puts "(some-malicious-code ...)" into this database, it won't be a danger as long as I'm only using #'read, since it will only return a list or a symbol.

  No.20897

>>20896
A user might enter "(foo". Other than that they won't have access to Lisp through read. I still would favor proper user validation for something like a website, but for something quick and easy it might not be bad.

  No.20901

>>20896
You'll want to limit what's READ, so read fields, not entire databases, so that a bad field can't extract everything. You'd want to establish an error handler anyways.

Also look into WITH-STANDARD-IO-SYNTAX and the dangers of *READ-EVAL* and whatnot.

  No.20912

>>20896
>Am I correct in thinking that #'read only reads in data, and doesn't do any execution?
No, but good question.
> (read)
(1 2 #.(format t "Hi!") 3)
Hi!
(1 2 NIL 3)
>

  No.21051

File: 1482453468301-0.png (210.03 KB, 200x113, Screenshot from 2016-12-22 18-05-25.png)

File: 1482453468301-1.png (349.35 KB, 200x113, Screenshot from 2016-12-22 18-37-15.png)

(defn -main
[composite]
(def vectormap [])
(loop [divisor 1]
(if (< divisor composite)
(if (integer? (/ composite divisor))
(do (def vectormap
(conj vectormap
(hash-map :divisor :number (/ composite divisor))))
(recur (inc divisor)))
(recur (inc divisor)))
vectormap)))


Why won't this run outside of the REPL?
I need to compile it so I can run it on my desktop, but I can't even get it to run in leiningen

  No.21071

>>21051
When you call it from the REPL composite is a number, but when called from the command line it is a string.

  No.21093

I have a question - is there a standard that every lisp dialects share ? More than just the syntax. What has been standardized to work with every dialects ?

  No.21094

>>21093
you can reasonably expect (lambda (arguments...) (code...)) and (if cond branch1 branch2) to work the same in any lisp dialect. Besides that, no.

  No.21095

>>21093
>I have a question - is there a standard that every lisp dialects share ? More than just the syntax. What has been standardized to work with every dialects ?
Disregarding all not Emacs, Scheme, and Common, this is still hard to say.

Many arithmetic and list functions, such as + and map, are present and named the same, but may behave slightly differently. Common Lisp's multiple return values are a big difference with many operations.

Even car and cdr behave differently. Common Lisp's car and cdr accept NIL, as an example.

There's still if, but even PROGN is begin with Scheme.

Scoping is generally the same, but not with Emacs Lisp. Many predicates and destructive operations have parallels, but follow different naming schemes.

Common Lisp has arbitrary length integers, Emacs Lisp doesn't.

So, only the most basic operations are shared and even then may behave differently. I would write this is why it's considered a family more than basic variations on a theme.

By the by, this thread is now full. I'll make the next later. Have a Merry Christmas and all of that.