[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Lisp General: Reader Macros Are Cool
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 52
Thread images: 6
File: Space-cadet.jpg (1 MB, 2001x773) Image search: [Google]
Space-cadet.jpg
1 MB, 2001x773
This is the Lisp General, ask any and all Lisp questions here. Below is a link to the general's pastebin which contains many links to various books, documentation, websites, and other interesting information.
Check the pastebin first:             Read the FAQ:
http://pastebin.com/u/g-lisp-general http://pastebin.com/aDfDm5sZ


>Here's the /g/ wiki's page on Lisp:
http://wiki.installgentoo.com/index.php?title=Lisp

>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)?
The previous thread:

https://rbt.asia/g/thread/47385606
>>
File: srefactor-elisp-format-buffer.gif (1 MB, 680x738) Image search: [Google]
srefactor-elisp-format-buffer.gif
1 MB, 680x738
>>47421975
https://github.com/tuhdo/semantic-refactor
>>
>>47422321
How neat. I've been wanting to do something similar with the Common Lisp pretty printing system for a while.
I should really start on that.
>>
File: plt-logo-red-shiny.png (40 KB, 256x256) Image search: [Google]
plt-logo-red-shiny.png
40 KB, 256x256
Who knew Racket had a manifesto?

http://www.ccs.neu.edu/home/matthias/manifesto/

> The creation of a programming language calls for guiding principles that point the developers to goals. This article spells out the three basic principles behind the 20-year development of Racket.

> First, programming is about stating and solving problems, and this activity normally takes place in a context with its own language of discourse; good programmers ought to formulate this language as a programming language. Hence, Racket is a programming language for creating new programming languages.

> Second, by following this language-oriented approach to programming, systems become multi-lingual collections of interconnected components. Each language and component must be able to protect its specific invariants. In support, Racket offers protection mechanisms to implement a full language spectrum, from C-level bit manipulation to soundly typed extensions.

> Third, because Racket considers programming as problem solving in the correct language, Racket also turns extra-linguistic mechanisms into linguistic constructs, especially mechanisms for managing resources and projects.

...
>>
>>47423505
So you can have JSON literals in Lisp.
https://gist.github.com/chaitanyagupta/9324402
>>
>>47423738
edn master race.
https://github.com/edn-format/edn
>>
>>47422925
The more I read about racket, the cooler it seems.
>>
>>47422925
Programming languages are compiler-human interfaces, a language that allows defining sublanguages is a massive sidestep and explains why Racket is still in obscurity after two fucking decades.
>>
>>47424019
Not every language has to be popular. Racket has its niche, and it's doing fine.
>>
>>47424019
well the thing is Racket isn't 20 years old, it used to be scheme until a few years ago.
I can't remember when it started to grow from a simple and regular Scheme implementation to really solid language with a good and sizable standard library
>>
I wrote this for a different thread. See if you can improve it.
(defun stars ()
(loop with number-list
for input = (progn (princ "Input a number (blank to exit): ")
(read-line))
for number = (parse-integer input :junk-allowed t)
when (zerop (length input))
do (return)
when (not (null number))
when (member number number-list :test #'=)
do (format t "You've already entered that number.~%")
else
do (format t "~v@{*~}~%" number nil) (push number number-list)))

All it does is read a number from the user and prints out that many asterisks. Any number previously entered is not to be printed again.
>>
>>47427525
(defun asterisks (n seen)
(flet ((get-next ()
(parse-integer (read-line) :junk-allowed t)))
(cond ((member n seen)
(format t "Number has already been seen;~%")
(asterisks (get-next) seen))
(t
(format t "~{~D~}~%" (loop :repeat n
:collect #\*))
(asterisks (get-next) (cons n seen))))))


Just for fun.
>>
Is it possible to write a /lispg/ thread bumping program?
>>
>>47430070
We've already discussed this. I'm not paying for a 4chan pass.

I think we have enough people by now who can bump it and have something cool to show us at the same time.
>>
>muh 50 year old language
>>
>>47430181
you're using a 50 year old language too
>ALGOL
>>
I recall reading some stuff about concurrency that mentioned that conses were holding Lisp back. I'm only a casual Lisp user, but I thought about it and thought it was pretty accurate. While conses are interesting conceptually, you don't actually need them in a Lisp implementation, and cons, car, cdr, cadr, etc. can be simplified with first, rest, nth.

My question is, for those of you who breathe Lisp, what would you say is the most fundamental aspect of Lisp?

I would say lists and homoiconicity. If you have those, then you have unambiguous syntax and the ability to use eval and macros freely.
>>
>>47430920
do you have a link to that material? i'm always up for more reading
>>
>>47427880
I'm not sure that's an improvement, but it's certainly different.

It's nice to see how people solve problems in different ways.

I suppose mine could be improved by changing the first two lines to:
(defun stars (&optional (number-list ()))
(mapc (lambda (x) (or (integerp x) (error "The stars list can only contain integers."))) number-list)
(loop with number-list = number-list


>>47431082
He was probably talking about this:

http://xahlee.info/comp/Guy_Steele_parallel_computing.html
>>
>>47432567

Things to Avoid

DO loops.
linear linked list. (lisp's cons)
Java style iterator.
even arrays are suspect.
as soon as you say “first, SUM = 0” you are hosed.
accumulators are BAD. They encourage sequential dependence and tempt you to use non-associative updates.
If you say, “process sub-problems in order,” you lose.
The great tricks of the sequential past WON'T WORK.
The programing idioms that have become second nature to us as everyday tools for the last 50 years WON'T WORK.

Well fuck
>>
>>47432567
>>47432657
> lists things to avoid
> doesn't present a way around it
Gee, thanks, Guy!
>>
>>47432710
The text is written by Xah Lee and it's about Steele's lecture
>>
>>47432736
I didn't have time to watch the lecture. But if Steele had given good alternatives (apart from using languages whose keywords I can't type), don't you think Xah Lee would have mentioned them?
>>
this list of books is interesting, even if you don't really care about Clojure, since the list was made by Rich Hickey, apparently these were the books that influenced him.
>>
>>47433353
fuck forgot the list
http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH
>>
>>47433366
i'm just going to comment on the books i read from that list:

>Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp by Peter Norvig
a classic, recommend

>The Art of the Metaobject Protocol by Daniel G. Bobrow
also a classic. but unless you're interessted in MOP skip this for now

> Purely Functional Data Structures by Chris Okasaki
amortize functional data structures via lazyness. good book, but you can probably skip this one for now

>ML for the Working Programmer, 2nd Edition by Lawrence C. Paulson
nice if you're into ML. these days i would probably pick ocaml though.
Functional Approach to Programming - Guy Cousineau comes to mind

>Artificial Intelligence: A Modern Approach (2nd Edition) by Stuart J. Russell
also a classic, recommend

>Essentials of Programming Languages - 2nd Edition by Daniel P. Friedman
basicly SICP part 2. the 2nd edition is hard to get and people complain about 3rd. be warned

>On Lisp: Advanced Techniques for Common Lisp by Paul Graham
classic text. maybe a bit dated.

>ANSI Common LISP by Paul Graham
okay-ish. probalby skip

>Programming in Prolog: Using the ISO Standard by W. F. Clocksin
good intro for prolog. i prefer:
The Art of Prolog: Advanced Programming Techniques - Leon Sterling, Ehud Shapiro and pair that with
Natural Language Processing for PROLOG Programmers
- Michael A. Covington and build your own watson

>Concepts, Techniques, and Models of Computer Programming by Peter Van-Roy
neat book. complement with harpers practical foundations for programming languages

> Structure and Interpretation of Computer Programs, Second Edition by Harold Abelson
have you read your SICP today???

>Object-Oriented Programming in COMMON LISP: A Programmer's Guide to CLOS by Sonya E. Keene
good to decent intro for CLOS

>How to Solve It: A New Aspect of Mathematical Method (Princeton Science Library) by G. Polya
also a classic, recommend
>>
>>47434884
>>ANSI Common LISP by Paul Graham
>okay-ish. probalby skip
Also; keep in mind:
http://cs.northwestern.edu/academics/courses/325/readings/graham/graham-notes.html
>>
>>47432710

He tried.

https://blogs.oracle.com/projectfortress/entry/fortress_wrapping_up
>>
File: hammock.jpg (72 KB, 500x500) Image search: [Google]
hammock.jpg
72 KB, 500x500
>>47433353
>>47433366

Item 40 is cute.
>>
>>47438009
> Hammock Driven Development
https://www.youtube.com/watch?v=f84n5oFoZBc
>>
I'm going through How to Design Programs and ran into a strange problem/question.

From Section III, Abstraction:
>Can we hope to define
function=?
, which determines whether two functions from numbers to numbers are equal f? If so, define the function. If not, explain why and consider the implication that you have encountered the first easily definable idea for which you cannot define a function.

The solution I found was:
; Function1 Function2 Num.MAX Num.MIN -> Boolean
(define (function=? func1 func2 top bot)
(cond
[(< top bot) true]
[else (and (= (func1 top) (func2 top))
(function=? func1 func2 (sub1 top) bot))]))


Which gives the appropriate true/false values for function one being
(+  a 3)
and function two being
(+  (- a 3) 6)
, as well as for the same function one and function two being
(+ a (abs a) 3)
for ranges 10 to 1 (true for the first examples) and 3 to -3 (false for the second example, because they're only equal for positive input and not all input).

However, the way that paragraph is phrased makes me feel like there wasn't supposed to be a solution, which means the one I found was wrong. Did I mess something up or am I just misinterpreting?
>>
>>47439516
It's possible if functions are total (always terminate) and the domain is finite.
>>
>>47439516
Ugh, sorry about that awful quoting, I didn't know code tags broke it.

>>47440226
I see, thank you.
>>
File: 500004885-03-01.jpg (45 KB, 600x450) Image search: [Google]
500004885-03-01.jpg
45 KB, 600x450
Why aren't Lisp machines still a thing?

Seriously. If I was a millionaire, i would pour tonnes of cash into developing a modern Lisp machine architecture.
>>
>>47440553
Can you run SBCL on your x86?
Congrats you have a LISP machine.
>>
>>47440553
Lisp machines are like Laserdisc players. Y'all keep comparing them to VHS when we have Blu-Ray now.
>>
>>47432657
I think it's exciting that the old knowledge won't be as useful.
>>47440564
Not really.
>>47440613
Not him, but modern UNIX systems don't compare at all.

Also, Laserdisc may have been analog, but you can't even play Blu-Rays without jumping through hoops to avoid DRM or giving into all of the restrictions, which actually makes it a pretty good analogy, since Blu-Ray is locked down shit and that's the path computers are headed down.
>>
File: wut.jpg (21 KB, 411x334) Image search: [Google]
wut.jpg
21 KB, 411x334
>>47432657
>linear linked list. (lisp's cons)
>>
>>47440754
What do you think it is? Were you going to be pedantic and say it's a node in a list?

http://cs.gmu.edu/~sean/lisp/cons/
>>
>>47440894
No, just that it's included in the "Things to avoid" list.
>>
>>47440754
the elements are not in contiguous memory
>>
>>47439516
I didn't read the book, but I can immediately give you an example of two functions that deliver the same results at all inputs (which is what you check for) but can still not be considered equal.
(define (f1 x)
(+ x 1))
(define (f2 x)
(set! *some-global* x)
(+ x 1))

Unless of course the book assumes that only pure functions are used (which would be pretty naive).
>>
>>47441848
The book hasn't touched on assignment yet.
>>
CLIM is actually awesome
GUI toolkits? Without needing to cram shit into an event loop?
SIGN ME UP!
>>
>>47442926
Is the scrolling pane bugged in macclim?
>>
>>47440553
What benefits would Lisp machines provide over the status quo at this point in history?
>>
>>47442987
I haven't noticed anything as such.
>>
is there anything like quicklisp for guile?
>>
>>47424019
JSON is a sublanguage.
PCRE is a sublanguage.
The C preprocessor is a sublanguage.
Massive sidesteps all?
>>
>>47430920
How do you build lists without consing, whether directly or under the hood?
>>
>>47432657
>parallel computing gotchas
i doubt anyone here does much that requires massive low-level parallelism
if you want to play with it, probably a good bet would be the connection machine simulator, which lets you run their massively parallel lisp dialect without needing an actual CM2+LispM:
https://github.com/g000001/Starlisp-simulator
good luck getting it running, there's probably readmes out there somewhere
>>
>>47440613
Best answer I've seen to the "what would today's Lisp machine be like" question. Today's Lisp machine would be exactly like SBCL. No, it doesn't run on the metal, but neither does anything else these days, and it's a blazing-fast and highly complete Common Lisp implementation. Why quibble?

I mean, I remember back when we were all fighting to get Open Genera running in emulation, none more so than Emunon, who was me. (Hello again.) Eventually I was just like, you know what? Fuck it. I remember back when I was a kid and it took endless dicking around to get anything interesting to happen with any computer more complex than an Apple IIe. Back when I was a kid, I had the patience for shit like downloading entire disk sets to install Slackware 3.4 on a Toshiba brick laptop with less processing power than a modern pacemaker, not to mention that back when I was a kid, that was the only option. I no longer have such patience. Happily for me, modern hardware and software makes amazing capabilities trivially easy to obtain, so I no longer have to put up with a ton of silly bullshit in order to start doing something that actually interests me. There's enormous value in such simplicity, which should not be overlooked.

Maybe you feel as though you were born too late, that there's no way to live up to the trailblazing pioneer heroes of days gone by. Well, there isn't, and in some ways that's a shame. But on the other hand, those trailblazing pioneer heroes did what they did so that those who came behind -- namely us -- wouldn't have to put up with buckskin tents and bathing once a month, and while it's fun to play with old things, eventually it just gets wasteful of time we could instead be spending on doing something really cool with the utterly fantastic tools of today.
Thread replies: 52
Thread images: 6

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.