lainchan / λ

Lisp General: (LAMBDA (&OPTIONAL (STREAM *STANDARD-OUTPUT*) &AUX (*STANDARD-OUTPUT* STREAM)) ...)

Lunch · 2019-01-18 21:34
>>12171 Ok anon, the code is in pic related. Basically, the only things needed for the equivalent? procedure are procedures: atomic-props, generate-values, and truth-table. Truth table gives us back literally the truth table, in linked list form, so we can traverse it As you can see, it uses generate-values which indeed generates all possible permutations of true and false, given n places/slots I did use some other procedures I had defined my own goodies module, like curry curryr, curryn, flatten and replace-multiple I also used (srfi 1) and (srfi 60) srfi 60 is important because it has a procedure "integer->list" which turns an integer into a list of booleans representing its binary value. really useful for generating boolean values. it also lets you specify how many bits you need, otherwise, 0 would be just a list of one boolean value (#f) I'm ok with this code, but I can sure polish it I'm also working on a function "infix->prefix" which does this (p implies (q and not r)) => (implies p (and q (not r))) (p iff r or not q) => (iff p (or r (not q))) (k or q implies r) => (implies (or k q) r) (p and q or j and not y iff u) => (iff (or (and p q) (and j (not y))) u) (p and (q or j) and not y iff u) => (iff (and (and p (or q j)) (not y)) u) it may look like I implemented it but it has bugs I do plan to use these procedures to help me out in class, so I do definitely want to implement this as It'd make my life easier Any feedback or questions?
Jim Hilger · 2019-01-18 22:09
i section off the phases of my life by the creation and death of lisp generals.
Unspecified · 2019-01-18 23:06
>>12182 acute-terminal-control anon, is that you?
(princ tripcode) -| · 2019-01-19 01:27
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: Implement a standard of your choice in the Lisp of your choice; it can be large or small. If you can't decide on one, why not a standard hash checksum?
(princ tripcode) -| · 2019-01-19 01:57
>>12180 This wasn't bad, per se, but the same image has been used for these threads for almost five years now. Also, you didn't have a title and while I didn't change the challenge this time, I did add to it drawing from a discussion I've had with someone learning Lisp lately. >>12182 That's interesting. >>12183 That would be me. As for CL-ECMA-48, I've decided against adding 8-bit support for now and will mostly be cleaning the code further. As for ACUTE-TERMINAL-CONTROL, I'll be adding to it as I recognize more good opportunities and I'll be correcting some flaws I've yet to fix entirely. I don't have much Lisp planned for this year, but I'll be picking at least a few more standards to play with. I'll also be taking my terminal libraries and porting them to Ada 2012 as ECMA_48 and Acute_Terminal_Control; it will be interesting to compare the two, then. This ties in to porting my main project from Common Lisp to Ada, as I wanted the utmost in reliability and whatnot; handling memory exhaustion is interesting, but not something one can do in purely portable Common Lisp. Currently, I quite like the idea of writing servers in Ada and clients in Common Lisp; that seems a very good way to go about it. What are your Lisp plans for this year?
Random · 2019-01-19 02:07
>>12181 although I took a different path with my implementation I feel like I can learn a bunch of things from the way you did it Your implementation is treating both p and q as equivalent expressions whereas mine require to use the same symbols in both expressions - I could *fix* that (though I wouldn’t because it’s not my intended behavior to begin with) by not using the same set of bound names for both expressions but then I would loose the ability to compare two expressions with a different number of variables.
Colmerauer · 2019-01-19 02:24
>>12186 >Currently, I quite like the idea of writing servers in Ada and clients in Common Lisp; that seems a very good way to go about it. I'd expect it to be the other way around, since Lisp is capable of such great error recovery. No excuse for a server being down.
synchronized · 2019-01-19 03:17
>>12181 Also I would be highly interested to read more of your code Would you like to collaborate on some scheme project ? I have a git instance just for that although I have no idea what to do / maybe work on a bunch of functional programming primitives to get started ? If you uploaded your codebase somewhere i’d happily test the whole thing and provide more feedback than the one below for the infix to prefix procedure, I believe that having a proc add missing parenthesis to an expression beforehand such as (p implies (q and not r)) becomes (p implies (q and (not r))) for example would dramatically simplify the job. Then left is just car, op is cadr and right is caddr Your atomic-props is a lot simpler than my equivalent procedure but i tried to get something efficient by traversing the structure only once Indeed, a lot of things you wrote there is really inefficient ( I guess you knew it already anyway), but again, your code is much more readable than mine so I do not think of it as a drawback.
Pulse · 2019-01-19 05:05
>>12191 Lisp is one my hobbies, I'd love to use it where applicable. >if you uploaded... I have to learn how to do git and all that stuff. I've only worked alone and have my code in my SSD. I can upload a another site, but that's not ideal since it depends on other code, so I'd have to end up uploading a lot of files. I'd be better to have a github or something similar. I'll take upon myself to learn git these weekend, since I have to do it anyways and it'd be nice to have backup of my other code. >for the infix to prefix procedure... I think you're right, I just have to tackle it more. I'm mainly having trouble with the unary operator "NOT" and how I'd make my function be able to take something like (not not p) and not give an error but I like your idea, maybe I should have a special function for formatting the NOTs and then I know all is left are binary operations, which makes it a hell of a lot easier >your atomic-props is a lot simpler ... traversing the structure only once >a lot of things you wrote there is really inefficient yes that's not something I'm not proud of but as you said, I went for readability I'll take a look at the code again and will try to make it less inefficient
cond · 2019-01-19 05:11
>>12186 >What are your Lisp plans for this year. A server written in Guile which provides data so my TV app can access it locally, and thus I can access my hdd from my TV. Not just limited to files though, I can get data from the internet itself and then tell the TV to use it (think a forum browser or something)
Morpheus · 2019-01-19 06:59
How hard is it to move between lisps or read other lisp code ? I'm learning emacs lisp and have gathered a lot of lisp books. My issue is some of these are emacs, some are scheme, some are common lisp so on. Will I be able to translate code examples to elisp and follow along with the books with much headache ? How transferable is lisp ability? If I learn elisp do I effectively know common lisp, scheme , clojure etc. Aside from minor changes ? Thanks . I'm a lisp newbie and overall a novice at best programmer .
drop · 2019-01-19 10:04
>>12196 Not very difficult if you grasp the basic concepts behind lisp. The most notable difference between lisp based languages are the so called lisp2 languages, such as common lisp and emacs lisp. They basically have a different namespace for functions and variables. Other than that its mostly a question of api differences.
Cowboy · 2019-01-19 12:30
>>12193 >a special function for formatting the NOTs I would make one for every operators based off their precedence.
Vasya Pupkin · 2019-01-20 16:16
>>12185 Archive of the old thread https://archive.is/HyacJ
Kay · 2019-01-20 20:05
>>12185 does anyone here use Common Lisp for quick scripting tasks?
Colmerauer · 2019-01-20 20:36
>>12226 I sort of do, but instead of writing scripts I write functions and call them from the REPL. It's a fair amount of effort to make a good script, so if you have the source code keeping a REPL open is easier. You don't have to deal with argument parsing or shell languages. It's a lot faster by default since you don't have to start a Lisp process every time you run your script. If you really want traditional scripts, there's probably a way to get at the terminal arguments with UIOP, and I think there's been some solutions that make starting a Lisp script super fast.
sizeof · 2019-01-20 23:45
>>12227 Would you share some of your scripts ? Just curious about scripting with Common Lisp
Nguoi La · 2019-01-21 17:28
>>12229 >Would you share some of your scripts? No. My laptop died the other day, I didn't have backups of the scripts, and I don't want to scrounge through old hard drives. If it helps, most of them would have used curl or grep if they were in bash. I used a lot of drakma and cl-ppcre.
nil · 2019-01-21 22:19
>>12227 That's interesting, any reasoning or numbers on how `sbcl --script` is not fast enough? Or is it mainly because the REPL approach suits your workflow better? CLI arguments are pretty convenient too with SBCL at least.
Backus · 2019-01-22 00:10
>>12199 Oh and I would just ignore two consecutive NOTs. In fact anytime you encounter two consecutive occurrences of the same boolean operation of arity 1, you can ignore it. Without side effects you can only apply the identity or the negation on a single Boolean, both can be simplified that way.
stack · 2019-01-22 02:46
>>12241 >any reasoning or numbers on how `sbcl --script` is not fast enough? I usually stick code into my 'sbclrc' file to load quicklisp and I'll often run SBCL on soykafty machines, so the startup time is pretty bad by default. When I say it's slow, I mean there's a noticeable pause. >CLI arguments are pretty convenient too with SBCL at least. I am sure CLI argument handling has a worse interface than function argument handling. Lisp handles optional, rest, and keyword arguments out of the box and has types instead of everything being bytes. A glance at the SBCL documentation makes me expect needing to write long CLI argument signatures in a special format to gain basic functionality. This isn't something specific to Lisp, it's easier to write Python modules and import them than it is to make a quality CLI program. Even with Python's argparse module, you can still expect a few dozen lines to make a decent CLI script. Unsurprisingly, Perl6 is particularly good for at this. They allow you to write a main function and then link its signature with the CLI arguments. https://docs.perl6.org/routine/MAIN Hell, you can probably assign an existing function to MAIN and have it do the right thing. It would be like having a (setf main #'drakma:http-request) , and then you instantly get a rival to wget or curl.
Linda Lee · 2019-01-22 14:17
>>12193 >>12191 I might be interested in joining a scheme project (depending on what you do) just so you know, you might have an extra pair of hands if you end up taking something up. I have some experience with clojure, none with scheme, and I have been doing scientific programming / data science for over 3 years.
sizeof · 2019-01-22 14:51
>>12254 Would be nice, if you drop me your email, i can invite you to my git server. I believe Kawa is an implementation that works over the JVM. Unrelated: regarding my definition of lequiv (the one with define-syntax on top in the old thread), I am now getting rid of the syntactic extension in favor of a simple procedure with quoted arguments. At first I thought that expanding to the same set of definitions each time would not be an issue, but the more I think about it the more I find it really ugly.
Debbie Charteris · 2019-01-22 15:54
>>12255 Can you say more about what the project is possibly? It would be interesting to work with lains on a scheme project if it is something interesting.
string · 2019-01-22 17:00
>>12243 I need to worry about it because I maybe have something like this (not not not not .... p)
XERXES · 2019-01-22 17:02
>>12256 Well we do not know yet, it can be anything. Hopefully not something overly ambitious to begin with. It can be a large project. The other lainon say he has worked in the field of scientific computing and data science. I am nothing more than a hobbyist for now, (not even in uni yet) I got interested in Scheme and Common Lisp (amongst a bunch of CS thingies over the years such as Ruby, Linux, C, system administration...) and I am learning everything I can about those. I have a very disparate knowledge which allowed me to take various jobs in my city where I generally succeed rapidly even when unfamiliar with the technologies / algorithms. So i’m not a total beginner but i’m by no means an expert in whatever field. Now about what to do, I had some ideas a while ago: - a Linux distribution where the maximum amount of things is written in Scheme - a Hexchat plugin to develop modules in Chibi Scheme or s7 - a Scheme to Common Lisp converter (using the language’s reader) - emulators (something simple to begin with) - a configuration manager (like Ansible) - a Scheme implementation of some software (ie. git, apt - a Scheme implementation with a specific goal in mind - anything you might suggest / something you need to solve a problem I believe we should work on some toy projects before setting for a serious one. Just the time needed to get used to working with each other. I already contributed to a CL project on github back in 2018. Also there is a bunch of things that needs to be done. - documentation: when software lack documentation we can just take the code and write the doc by ourselves - testing software (finding working external libraries in Scheme is hard, indexing them and testing them over a range of implementations will save a bunch of time for everyone) - something compilant with this thread’s challenge - ... Those are ideas, I don’t expect to do all of this however soon, but if there is something you want to work on, i’m available for the entire year, until August or September.
Demeere · 2019-01-22 17:14
>>12254 >>12258 I'm interested, I do need experience doing projects with other anons. I'm the anon with the inefficient equivalent? procedure.
Bobby Newmark · 2019-01-22 17:31
>>12257 if you have an even number of nots, leave none, if you have an odd number of nots, leave one. I think you need to create a new function for this. Working on it right now. >>12259 So how much are we right now ? 3 or 4 ?
Fred Nurk · 2019-01-22 18:09
>>12255 >Would be nice, if you drop me your email, i can invite you to my git server. Cool, but we need to figure out the logistics, maybe meet in the IRC some day, cause I am not going to write down my email here. But maybe is better if we just start a github repo, not a private server. I dont know. >>12258 > a Linux distribution where the maximum amount of things is written in Scheme I think this is a cool idea, implemented in the guixsd thingy: https://www.gnu.org/software/guix/ They lack a graphical installer, tho. That might be a good project. Just throwing ideas arround. >>12260 >So how much are we right now ? 3 or 4 ? I think at least 4.
Six · 2019-01-22 18:14
>>12261 Yep, the irc is a good idea
Just another Random Lainon · 2019-01-22 18:50
>>12257 After a bunch of tries, it appears that it’s better to force the use of parents around nots. Existing solutions (which I did not find) must be really really complex. I might have found something relevant here ftp://ftp.cs.indiana.edu/pub/scheme-repository/code/lang/pratt.scm >>12262 >>12261 So I will be connected on the IRC in #programming just drop by and say you are here for the groupe projects and we’ll start
Frank Garza · 2019-01-22 19:16
>>12264 >>12257 Got pratt.scm to work on my computer: bash wget https://people.delphiforums.com/gjc/siod.zip mkdir siod && cd siod mv ../siod.zip ./ unzip siod.zip make linux sudo make install siod # > (load "siod.scm") # > (load "pratt.scm") # > (pl '(not not p and q)) # => (and (not (not p)) q) I'll check if I can translate this to work on Guile.
Linda Lee · 2019-01-22 19:23
>>12264 I'm on the rizon server. Freenode says it needs SASL or something and I use ERC, which isn't in their list.
J.C. Denton · 2019-01-22 19:29
>>12266 I'd rather write my own, but i'll reference it definitely.
let · 2019-01-22 19:30
>>12267 #programming on irc.lainchan.org:6697 can't you connect there ?
Neo · 2019-01-22 19:34
soykaf, it says connection failed probably im doing something wrong
H.R. Giger · 2019-01-22 19:37
>>12270 If you are using tor, a bunch of nodes were derezzed, if not, try to connect to 6667 without SSL.
hash table · 2019-01-22 19:39
>>12271 what's code 111 ?
overriding · 2019-01-22 19:40
i have to go to class in a bit anyways, you guys do without me, perhaps at home I can connect, cheers.
Cypher · 2019-01-22 20:44
>>12273 Okay, will reconnect in a few minutes
Zuse · 2019-01-22 22:57
>>12278 now it's stuck at the connecting phase the web client works though
(princ tripcode) -| · 2019-01-23 04:41
This new organizing I see arising here is interesting. I'll be in the Lainchan IRC, per the usual. Try to avoid using this thread for IRC questions and whatnot in the future. >>12188 >I'd expect it to be the other way around, since Lisp is capable of such great error recovery. No excuse for a server being down. I can see that perspective, as well. My thinking was Ada would be able to withstand memory exhaustion and other errors more reliably than Common Lisp and how Ada has standardized support for multiple threads of execution at the language level. I can certainly see the appeal of using Common Lisp for a server, however, and it would in all likely practicality be fine. I may find it interesting to build a server for some protocols, such as Gopher, in Common Lisp and Ada and compare the two. As for clients, customizability is of much greater importance and I don't see Ada as having many particular advantages there for a normal user on a typical machine. Still, I may try my hand at writing two clients for some protocols. There's certainly no harm in comparing those as well. >>12226 >does anyone here use Common Lisp for quick scripting tasks? I don't at all know how to use POSIX sh beyond launching single commands, semicolons, and ampersands; so, yes, I do my file manipulation in Emacs' Dired or with a Common Lisp program using the various file system and pathname facilities. I've had issues before where the file names are predictable, but there's hundreds of thousands of them and typical sh globbing is far too slow, but I refuse to learn enough sh to write a program that would work for the particular instance and then break when the file name contains an innocuous character, so I use Common Lisp for the simple task and need not worry about scary file names blowing up the program for no good reason. Startup time is never an issue, as I always have multiple REPLs running and simply use those. Rather than dig through my history looking for a good one, why don't you ask me about, say, a particular file manipulating task you'd care to see in Common Lisp and I'll show you how I'd do it? I do have this particular example, however; this is an alarm clock I used some times, since I don't shut my machines down. It's only necessary to use BORDEAUX-THREADS if you want to avoid locking up the REPL in the interim. I just used SBCL's SB-EXT:RUN-PROGRAM directly, rather than a library, because I only needed it to work in a single implementation, although I dislike programs that only run in SBCL: (defun make-alarm (second minute hour day month year sound) (bordeaux-threads:make-thread (lambda () (sleep (- (encode-universal-time second minute hour day month year) (get-universal-time))) (sb-ext:run-program "/usr/bin/mplayer" (list "-loop" "0" sound) :wait nil)) :name "alarm"))
Wirth · 2019-01-23 10:40
>>12289 I am the datascience lainon, I could not join yesterday, but i will be hanging arround there today as much as i can
Naomi Nascimento · 2019-01-23 13:41
>>12282 Nice to hear you were able to connect. I probably wasn’t there though >>12294 Ok cool I’ll be there too
Yu-ichi · 2019-01-23 16:58
>>12226 Yeah, I find CL very useful for shell scripts, namely because of the interior shell library. http://quickdocs.org/inferior-shell/
Knuth · 2019-01-23 18:07
>>12300 Guile has pipes, is this library better than Guile's ? Also, I started out with CL but moved to Guile. Guile is more script like for me, plus its Scheme. CL is nice though, wish it came with threads and networking stuff like Guile does.
Mentat · 2019-01-23 21:07
>>12301 Well Guile is a specific scheme implementation. There are libraies that add threads to CL that are fairly standardized. Sadly they are just traditional threading stuff from what I've found. No fancy erlang concurrency, and no STM. Also are you talking about this library? https://www.gnu.org/software/guile/manual/html_node/Pipes.html If so this is nothing like inferior-shell, inferior-shell is a macro that allows me to dip in and out of shell and CL with , and `. If I had to call functions and interact normally, then I'd just use Haskell via the turtle library
Ishikura "Tatsu" Tatsuhiko · 2019-01-23 23:14
>>12305 So weird, I wrote a macro like that too, but it's basic, only so I can do bash like stuff within the REPL. (read-hash-extend #\. (lambda (c p) (system (apply string (span-iterate (thunk (read-char p)) (disjoin eof-object? (curryr memv '(#\nl #\\)))))))) but It can't do cd properly so I made a cd macro too scheme@(guile-user)> #.uptime 18:14:30 up 9 days, 1:49, 0 users, load average: 0.11, 0.24, 0.30 $3 = 0 scheme@(guile-user)> #.free total used free shared buff/cache available Mem: 7851516 995368 3758884 135872 3097264 6416572 Swap: 0 0 0 $4 = 0
Nobody important · 2019-01-24 14:05
>>12295 Sorry for spamming the thread with irrelevant content. People connected on the irc already: tng (me), Yeikoff The irc channel is #programming on irc.lainchan.org:6697 There is a webirc here: https://lainchan.org/irc.html
Sabo Engle · 2019-01-24 14:48
Using CL, I have a hash table whose values point to certain cons cells of a list. I want to be able to modify those cons cells itself, namely, to set a cons to its cdr so as to remove the particular list item without traversing the entire list. But calling setf on the return value modifies the value in the hash table rather than the underlying list. As in... CL-USER> (let ((list (list 1 2 3)) (ht (make-hash-table))) (setf (gethash 1 ht) (cdr list)) ; at this point it's (2 3) (setf (gethash 1 ht) (cdr (gethash 1 ht))) ; I want to edit the list here (values list (gethash 1 ht))) => (1 2 3) => (3) Is there a way to setf things to a place a hash table value points to, rather than where the hash table value is? Or am I solving this problem completely wrong?
Spike Spiegel · 2019-01-24 21:41
>>12311 Sure, there is one easy way, use references. The following is from my own standard library (defpackage #:reference (:documentation "Provides a reference") (:use #:cl) (:export :ref :ref-p :! ::=)) (in-package reference) (defstruct ref contents) (defun ref (x) "Creates a reference out of x" (make-ref :contents x)) (defun ! (ref) "Grabs the contents of a reference" (ref-contents ref)) (defun := (ref x) "sets the reference value to x" (setf (ref-contents ref) x)) (defun (setf !) (x ref) "sets the reference value to x" (:= ref x)) I also use this package, so not to namespace it CL-USER> (defparameter *ref* (ref (list 1 2 3))) *REF* CL-USER> (defparameter *hash* (make-hash-table)) *HASH* CL-USER> (setf (gethash 1 *hash*) *ref*) #S(REF :CONTENTS (1 2 3)) CL-USER> (:= *ref* (cdr (! *ref*))) (2 3) CL-USER> (gethash 1 *hash*) #S(REF :CONTENTS (2 3)) T CL-USER>
JARGON · 2019-01-27 21:55
How are Racket's libraries? I've read conflicting information about them. Some say they're great, while others say they're terrible, but both sides blame "computer scientists" for the quality and documentation. I've also read that most of Common Lisp's libraries are also badly designed and documented, so there might not be much practical difference. Is there any reason besides aesthetics to choose one over the other (disregarding libraries)?
Pris · 2019-01-28 01:22
>>12346 >How are Racket's libraries? I've read conflicting information about them. Some say they're great, while others say they're terrible, but both sides blame "computer scientists" for the quality and documentation. It's hard to imagine the kind of person who hates Racket's documentation. Racket has two sets of documentation. One is a reference guide and the other is a set of tutorials. The documentation is extremely thorough. Racket's "pict" library includes image examples for most if not all of the functionality. Compare that to something like the documentation for Python's Pillow, which has almost no images, despite being an image processing library. If someone says Racket's documentation is bad, it's probably because they were reading the reference documentation instead of the Racket guide. >Is there any reason besides aesthetics to choose one over the other (disregarding libraries)? Common Lisp has a standard and several implementations. Racket has a single reference implementation. In comparison, C, C++, Fortran, and Ada have standards and several implementations. Python, Perl, and Ruby are known for their highly popular reference implementations, although there are multiple implementations and Ruby happens to have an ISO standard for an older version of the language. Common Lisp is well suited for long term stability. Racket is at the forefront of programming research and comes with batteries included. Common Lisp is image oriented. It's designed for programs that never quit, but it can do scripts. Racket is batch oriented. It's designed for scripts, but it can do programs that never quit. In comparison, Erlang and SmallTalk never really quit. They're image oriented. Individual evaluations may terminate or error out, but the run time does its best to stick around. C, Java, C++, Python, Ruby, and Perl are built to end when their main routine terminates or when the file being run has no more lines to run. They're batch oriented.
The Oracle · 2019-02-01 15:16
hiring and training beginner Common Lisp programmers ~$10/hr drea8an@yandex.com
Sabo Engle · 2019-02-01 17:27
>>12346 I use racket extensively and used many languages before. In my experience racket has some of the best documentation around.
Erik Johansson · 2019-02-01 17:57
>>12346 There are some nicely done libraries in common lisp, namely trivia (adds pattern matching to common lisp) I find I didn't care for racket for many reasons. One namely being the subpar editing environment (compare slime and racket mode), and various ways on how the language worked. One such example is the type system. In racket to type structs I have to go into typed racket, which doesn't always work nicely. In CL I can just type my functions and structs trivially and use that to get performance speed ups and nice type checking (its powerful enough to form adts)
Unsigned · 2019-02-01 18:13
>>12185 Howdy folks. Hope everyone's been having a fantastic February. I'm relatively new to lisp and functional programming (basically been programming in object-oriented and scripting languages, since that's what they teach), but I want to learn Clojure Say I'm moving away from C++ to Clojure, and have this structure: struct Tag{ const std::string directory; const std::string filename; std::string tag, new_name; Tag(const std::string& dir, const std::string& fname) : directory(dir), filename(fname), tag(""), new_name(fname); }; Basically, I want to be able to manipulate the "tag" and "new_name" fields of my structure based on user input, and make sure that I can't change the directory or the filename. Would a hash map be enough for this? I'm picturing something like using a "set" function for the fields I want to modify, but don't know how I can guarantee that certain parts of my structure won't change. Here's what I have so far: user> (defn make-tag (dir_ fname) (hash-map :directory dir_ :filename fname :tag "" :new_name fname)) user> (defn tag-change-name [tag new-filename] (assoc tag :tag new-filename)) user> (tag-change-name (make-tag "~/Desktop/" "Test.png") "Hot Dog.jpg") {:directory "~/Desktop/", :filename "Test.png", :tag "Hot Dog.jpg", :new_name "Test.png"} Open to advice and ideas!
SHODAN · 2019-02-02 21:49
>>12397 I don't know about Clojure, but I know in CL you can have read-only struct fields. Although you can modify them if you want anywyas, they're more for documentation purposes. Unless the user has access to the struct and you want guarantess of non change, then I'd just make a normal struct, and have the program change the struct fields you programmed them to change, and leave the others untouched.
Terzibashjian · 2019-02-03 16:25
>>12392 Care to expand on the nature of the training and job on here? Might be interested
Faye Valentine · 2019-02-19 03:03
Took me over an hour to get through the first 45 pages of SICP; I haven't gotten around to the exercises. I feel like a bit of a fool, but even if it's slow the learning is sure. How long did it take lain to get through SICP and get down the basics?
Case · 2019-02-19 18:57
>>12583 I spent about a month on the first chapter because of that stupid coin-counting challenge: reimplementing their tree-recursive coin counting algorithm to be tail-recursive. The best idea I had was to enumerate all possible combinations of coins, filter out combinations which exceed target value or combinations which reach the value. I think the algorithm should stop when all possible combinations exceed or meet the target value Enumerating combinations goes something like this: (iter a b '()) => a (iter a b '(a)) => b (iter a b '(a b)) => a a (iter a b '(a b aa)) => a b (iter a b '(a b aa ab)) => b b (iter a b'(a b aa ab bb)) ... I'm leaving out the filtering steps of course. The hardest part is figuring out when to end the computation.
DEBUG-CONTENTS · 2019-02-19 19:27
>>12583 I think I saw somebody somwhere else on the site recommending reading The Little Schemer first for a softer intro and being better prepared for SICP.
Motoko Kusanagi · 2019-02-20 02:27
>>12597 I would also recommend this But I think taking a glimpse at what SICP is about first might help *getting* the little schemer; notably the abstraction/composition basics
Ein · 2019-02-20 02:41
>>12597 Continuations and the Y combinator in TLS were harder to get my head around than anything in SICP.
Special Agent Bob · 2019-02-20 09:28
>>12583 I am on the second chapter. and its been over 2 years since I started. I did most of the exercises tho. And took breaks, and did personal projects and did a bunch of moocs on lisp and functional programming. i plan to finish sometime... when i can If you are reading sicp is beacuse you want. enjoy it, take your time to understand the concepts (they do pay off) and DO THE EXERCISES. It is not a race, its a hobby. But hey, 1.5 chapters through sicp made me one of the best programmers I have ever worked with. so go on and read you sicp.
Davis · 2019-02-20 09:37
>>12603 this. that apparently friendly Socratic style of The Little Schemer gets uglier the further into the book you get. Re: books and how long you spend on them. who cares as long as your enjoying yourself.
(princ tripcode) -| · 2019-02-23 20:47
How drab of me. I was so busy with managing other things that I forgot the anniversary this year; the anniversary is the twelfth. In any case, this general has now been going on for five years now. It's interesting to consider everything that lead me to this point. As for what I've been doing, I've not been programming in Lisp much lately, although I'll let you know when I implement more standards, as I plan to.
string · 2019-02-24 07:07
>>12353 Your distinction between batch and image (never heard this term) seems pretty arbitrary, to make any image a batch just exit the interpreter and to make an image just loop back to the main function of the interpreter
Erik Johansson · 2019-02-25 11:07
This seems inconsistent. (setf x '(a b c)) => (A B C) (delete 'a x) => (B C) x => (A B C) (delete (nth 0 x) x) => (B C) x => (A B C) (delete (nth 1 x) x) => (A C) x => (A C)
Gyula Kovacs · 2019-02-25 12:05
>>12680 You're critiquing a side-effect. Delete is a destructive operation and makes no guarantees about the original list.
Vasya Pupkin · 2019-02-25 20:18
I'm thinking about ditching shell scripts for some lisp variety. Currently conteplating something small that i could build/grasp/debug myself, with s9fes being #1 contender. How stupid am i? Should i go with a solid established player instead?
Cereal Killer · 2019-02-27 13:55
>>12681 >Delete is a destructive operation and makes no guarantees about the original list. Isn't modification of the original list the whole point of a destructive function?
Pris · 2019-02-27 20:01
>>12707 usually you'd want an immutable interface, to return a new list whilst keeping the older one intact
if · 2019-02-27 20:09
>>12680 > (define x '(a b c)) > x '(a b c) > (remove 'a x) '(b c) > x '(a b c) > (remove (list-ref x 0) x) '(b c) > x '(a b c) > (remove (list-ref x 1) x) '(a c) > x '(a b c) >
Neo · 2019-02-27 22:24
>>12709 >>12710 Yes, if I didn't want to change the original list then I'd use remove. I want to change the original list. Why does delete only work sometimes?
Unidentified · 2019-02-28 02:38
>>12707 >>12711 You're intended to use the return value of delete, which is correct in all cases. This way it has the same interface as the pure function remove and can be used as a drop-in optimisation when it's permissible to clobber the original cons structure. It's trivial to define a delete-in-place macro if that's the behaviour you're after. (defmacro remove-in-place (item list) `(setf ,list (delete ,item ,list))) In general you should stick to non-destructive functions unless you do need to optimise a piece of code.
Tomohisa "Tom" Kanezaki · 2019-02-28 03:06
>>12713 >optimisation So the real purpose of destructive functions is to execute faster by not creating new cons cells? But in what way does it differ from remove at the cons cell level if it sometimes has the same effect? If delete returns (A B) but x is still (A B C) , doesn't that mean a new list had to be created for it to return? >macro Yeah, I was just curious.
hash table · 2019-02-28 03:51
>>12714 As far as I understand it that's the case. Since this is CL there's probably also some weird historical reason they're in the language. Scheme has a much more limited set of destructive functions. >But in what way does it differ from remove at the cons cell level if it sometimes has the same effect? Cons cells are pairs, typically consisting of a datum and a pointer to the next cell. in the case of removing/deleting the second element of a list, remove creates a new list of cells until it reaches the element to be skipped, whereas delete rewrites the first cell's pointer to point directly to the third element. This is why x wasn't affected when you removed the first element; there was no need to modify anything, it just returned the second element which in turn points to the rest of the list. The following interaction may help clarify how it works and hint at the kind of nasty bugs that may arise when destructive functions are used carelessly. CL-USER> (defvar x '(a b c)) CL-USER> (defvar y (remove 'a x)) CL-USER> (setf (car y) 'd) CL-USER> x (A B C) CL-USER> y (D C) CL-USER> (defvar z (delete 'a x)) CL-USER> (setf (car z) 'd) CL-USER> z (D C) CL-USER> x (A D C) CL-USER>
Naomi Nascimento · 2019-03-01 10:58
>>12716 That makes a lot of sense, thanks Lain!
Joe Bloggs · 2019-03-01 23:39
I don't get macros. I've been using Lisp for academic projects about 2 years now, I've written about 1000 lines of ANSI Common Lisp and I've never written a macro. I don't get what it gives me that a lambda or regular function won't.
cdr · 2019-03-02 03:53
>>12724 Think about expanding the language. How would you incorporate pattern matching into the language? Macros allow this to happen quite elegantly. Other such examples are cond, a proper module system ontop of CL packages, adding monadic do syntax, or agment missing features into the language Some domains damand less macros, for example defining data structures. However this is only true until you try to inject laziness into structs, in which case you need to generate a lazy constructor and eager getters and even change the type signature of the struct.
Dox · 2019-03-02 17:19
>>12668 >to make any image a batch just exit the interpreter Yes, this is often trivial. >to make an image just loop back to the main function of the interpreter It's much harder than it sounds. A working image system needs to support hot loading, live debugging, and be salvageable no matter what user code is loaded. Restarting or shutting down the system as a way of handling upgrades, changes, or errors is not an option.
Moore · 2019-03-05 15:59
>>12724 I have never written a macro in lisp. but because i know my lisp, i was pretty comfortable doing some metaprogramming in R. The whole point of metaprogramming: it is extremely specific. it solves the problem that the language wont solve for you. If you never encounter such a problem you will never metaprogram. but when you encounter such a problem. metaprogramming will be extremely useful.
Nobody important · 2019-03-05 17:26
>>12664 Are you abandoning Lisp?
Mario Rossi · 2019-03-05 17:29
>>12707 I had trouble with this too. Basically, side-effecting functions like delete may modify the list you pass in. What they really do is recycle exisiting cons cells so as to not be wasteful.
hash table · 2019-03-05 17:30
>>12683 But why are you doing this?
setq · 2019-03-05 17:35
>>12724 Then it's time to read On Lisp and Let over Lambda anon.
⍕ · 2019-03-05 21:15
>>12714 Here's an example that might clarify why you need to use the return value from delete: (let ((foo (list 1))) (delete 1 foo)) FOO starts out pointing to the list (1), which is really a cons cell (1 . NIL). If we delete all instances of 1 from FOO, and we want this to be reflected in FOO, then we need FOO to be pointing at the symbol NIL. There's no way for DELETE to mutate a cons cell into the symbol NIL, and because DELETE is a function (not a macro) there's no way for it to somehow reach back into wherever its arguments came from and modify what was previously pointing to the cons cell. This is why you always have to use DELETE's return value.
(princ tripcode) -| · 2019-03-06 07:13
>>12392 This is a notice that I contacted this fellow and he's not gotten back with me. I'm inclined to believe this job offer was fraudulent, although it was already a terrible offer as it stands. The only reason I've not deleted it is because it has a reply here, it's rather old, and perhaps this fellow is simply lazy instead of scamming. >>12683 >I'm thinking about ditching shell scripts for some lisp variety. Here's a relevant post of mine: >>12289 >Currently conteplating something small that i could build/grasp/debug myself, with s9fes being #1 contender. How stupid am i? Should i go with a solid established player instead? I wouldn't think you've given enough information for this to be answered. Outside of launching single programs, I avoid using POSIX sh entirely. I much prefer to use Common Lisp for any light automation programming. >>12762 >Are you abandoning Lisp? No. I have no intention to stop programming in Lisp nor to stop creating these threads. Why would you think otherwise?
byte · 2019-03-07 02:59
link appears dead: http://definitelyaplug.b0.cx/post/emacs-reader/ I cannot find archived/cached page. Does any lainon have offline copy? if it was worth reading that is
Crazy Jake · 2019-03-07 07:51
>>12771 It appears to be on the Wayback Machine: https://web.archive.org/web/20130213044635/http://definitelyaplug.b0.cx/post/emacs-reader/
Incognito · 2019-03-07 11:02
https://queue.acm.org/detail.cfm?id=2068896
Yu-ichi · 2019-03-07 18:24
Hello /lisp/, I'd like some suggestions for improvements on this short program that I've written. I'm relatively new to programming in Lisp, and there's a lot of things that I'm sure could be done better. For one, I'd like to see if I can handle my list in a non-destructive manner. But I still want to keep the part where I print out parts of the list, but with one modification in the middle, and then pass the list without that modification as an argument later on. The program is meant to print out the process of Euclid's extended GCD algorithm, and return the value of the GCD. Due to the nature of that algorithm, it seems like I need to pass on the values from the previous 2 iterations every time. Originally there was also an argument q, but I found a way to derive it from the other args. I'd like to reduce the number of args further if possible, but I'm not seeing any ways. lisp (defun extended-euclid-print(x y) (if (< x y) ;;Ensure that x >= y (progn (setq temp x) (setq x y) (setq y temp))) (print '(ri qi si ti)) (print (list x '_ 1 0)) (print (list y (/ x y) 0 1)) ;; the 1's are from i-1 (defun ext (r1 r2 s1 t1 s2 t2) ;; the 2's are i-2. (setq i (list (mod r2 r1) '_ ;;this is to be q, only for printing (- s2 (* s1 (/ r2 r1))) (- t2 (* t1 (/ r2 r1))) )) (if (= 0 (mod r2 r1)) ;; to prevent division by zero. (progn ;;case: remainder is zero. print and exit. (print i) r1) (progn ;;remainder is non-zero, continue algorithm. (setcar (cdr i) (/ r1 (mod r2 r1))) ;;value of current q. (print i) ;;Print out this iteration of the table. (setcar (cdr i) r1) ;;replace q with r1, to pass on as new r2 (setcdr (last i) (list s1 t1)) ;;success! s1 and t1 appended to i (apply 'ext i)) )) ;;Preconditions: (where x is r at i=0, and y is r at i=1) (ext y x 0 1 1 0) ;;this launches into i=2 )
(princ tripcode) -| · 2019-03-07 19:54
>>12775 >Hello /lisp/, I'd like some suggestions for improvements on this short program that I've written. I'm relatively new to programming in Lisp, and there's a lot of things that I'm sure could be done better. Alright. I never was fond of treating a general name as if it were a board, but I still see people using that notation. >For one, I'd like to see if I can handle my list in a non-destructive manner. But I still want to keep the part where I print out parts of the list, but with one modification in the middle, and then pass the list without that modification as an argument later on. An easy way to do this is to simply use COPY-LIST. >The program is meant to print out the process of Euclid's extended GCD algorithm, and return the value of the GCD. >Due to the nature of that algorithm, it seems like I need to pass on the values from the previous 2 iterations every time. Originally there was also an argument q, but I found a way to derive it from the other args. I'd like to reduce the number of args further if possible, but I'm not seeing any ways. I'm only going to be improving what you wrote, without changing the algorithm your program implements. Be careful to observe how I change your parentheses and their spacing: (defun extended-euclid-print (x y) (if (< x y) ;There's PSETQ for this. Also, your TEMP was a global, which you shouldn't do. (psetq x y y x)) (write-string "(RI QI SI TI)") ;You may as well use a string at that point. (print (list x '_ 1 0)) (print (list y (/ x y) 0 1)) (labels ((ext (r1 r2 s1 t1 s2 t2) ;You use FLET or LABELS for local functions, not DEFUN. (setq i (list (mod r2 r1) ;Your I here seems to be another global; you should correct this. '_ (- s2 (* s1 (/ r2 r1))) (- t2 (* t1 (/ r2 r1))))) (if (zerop (mod r2 r1)) ;You can use ZEROP to check for zero and should. (progn (print i) r1) (progn (setcar (cdr i) (/ r1 (mod r2 r1))) ;What is SETCAR here? That's not standard. (print i) (setcar (cdr i) r1) ;You should be using SETF on CAR or CDR for this. (setcdr (last i) (list s1 t1)) ;You could even use RPLACA and RPLACD. (apply 'ext i))))) (ext y x 0 1 1 0))) ;You can encode preconditions and whatnot with ASSERT. As you can see, this is a very brief improvement. To sum, if you have an internally destructive algorithm that you want to be pure, simply use COPY-LIST. You could also take a look at FORMAT for advanced formatted output; I'd be glad to help you with what you want with that. Feel free to ask any questions once you've observed my changes. Again, note that I've not modified the algorithm; I've simply formatted it correctly and made some local changes where appropriate.
typedef · 2019-03-07 22:59
>>12776 (if (< x y) ;There's PSETQ for this. Also, your TEMP was a global, which you shouldn't do. (psetq x y y x)) One-armed IFs are gross -- use WHEN for side-effecting stuff like this. SETQ is a historical relic -- just use SETF for everything. But if you're just swapping two variables you don't need PSETF at all -- you can use ROTATEF. (when (< x y) (rotatef x y)) >>12775 Instead of keeping a list of arguments in a (global) variable i and then APPLYing EXT later, use LET (or LET*) to store a bunch of variables and then call EXT normally with (ext ...).
Unsigned · 2019-03-08 20:21
>>12770 You said you're not using Lisp, implying you have no use for it because you haven't written in it.
(princ tripcode) -| · 2019-03-10 19:54
>>12789 >You said you're not using Lisp, implying you have no use for it because you haven't written in it. I simply haven't been using Lisp as much as I'd care to. I haven't been programming at all as much as I'd prefer to. There's always multiple projects, where I can choose any of the suitable languages I know, to accomplish varying goals, where I can derive my own different libraries for the task, and all of that manner of thing. It's better to be too busy than it is to be bored. It's easy to be so busy one doesn't actually do much, though.
(princ tripcode) -| · 2019-03-19 16:58
The USOCKET library is merely an admittedly thin layer over the BSD Sockets API. A cursory glance at BSD Sockets shows it to be unnecessarily complicated and so disgusting. The IOlib library has several dependencies, including non-Lisp dependencies, and so I've not given it more than a cursory glance. I intend to write my own network library for Common Lisp. If any of you all are interested in the details already, then I'll show you what I have so far, but I'm currently looking for resources on older network functionality for inspiration. Do any of you have any resources on Genera's network functionality; I've been looking for a short while, but haven't found much in the way of details yet. Unlike most of my other programs and similarly to SHUT-IT-DOWN, I expect to license this library under the CC0 Public Domain Dedication. Making a network request should in no way be more laborious than making a filesystem request, at the least, I think.
Liet Kynes · 2019-03-21 14:35
I'm a teacher of programming in high school. I'm seriously considering using Racket and its teaching languages for doing this deed, combining stuff from HtDP and other beginner programming books like The Little Schemer. Is this reasonable? Am I letting my personal preference fool me? Any advice on this subject will be appreciated.
Agent Smith · 2019-03-22 06:28
Anyone here with experience in Hylang (http://docs.hylang.org/en/stable/)? I just found out about it today; a Lisp in Python. I'm curious if anyone has managed to get it running on a hosting service and what they used it for.
Tyrell Wellick · 2019-03-22 07:46
>>12924 Racket was designed to be an easy teaching tool while remaining practical, so i dont see why that would be a bad decsion.
car · 2019-03-22 13:47
What's the performance difference between LLVM and SBCL?
queue · 2019-03-22 15:53
>>12937 Do you mean Clasp?
progn · 2019-03-22 20:22
Made a clock with Clojure. The result is pleasing. https://github.com/netb258/clj-clock
Sipho Nkosi · 2019-03-23 01:16
>>12939 Yes.
Trinity · 2019-03-23 10:42
>>12937 SBCL is apparently faster, at least in pic related instance. Source: https://youtu.be/mbdXeRBbgDM
Just another Random Lainon · 2019-03-23 17:18
Why is this needed to read char by char from a stream? (do ((char (read-char stream nil) (read-char stream nil))) ((null char)) (print char)) The description for the use of char is: char string index => character
Koos van der Merwe · 2019-03-23 19:14
>>12951 nvm it makes sense now.
Judge Fang · 2019-04-01 21:14
can any lainon plz post link to webpage featuring standard complacency of CL implementations? That page also mentioned which implementation guarantees tail call optimization.
(princ tripcode) -| · 2019-04-21 05:30
So, what have you all been working on lately? I've been wanting to do some more practical work with Common Lisp, but various other concerns have been getting in the way, mostly related to networking and concurrency, both of which I intend to attack in my own way, but haven't gotten around to yet. I've been doing some very light and specific JSON processing with Common Lisp lately and CL-JSON was very slow for getting a single property as of the last time I used it, since it creates the entire object; I had a good solution I wanted to see if I could distill into a library, but in going about this had to refresh myself on how awful JSON is and how you can't reliably parse it without processing every character, meaning my original approach will likely never come close to being beaten by a more general solution, although I may continue with it at some later point. Put simply, the entire idea was to allow efficient processing of JSON by operating solely on the textual form for as long as possible, rather than parsing it to data structures that can then be operated on as wanted; one advantage of this is being able to process incomplete JSON in some ways, as an example. Really, I suppose I simply got sick of it early on. The chosen name is JSON-SUCKER, since that implies JSON is like kicking dead whales down the beach. I've recently come across this Gopher client, clic, written in Common Lisp: gopher://bitreich.org/1/scm/clic gopher://hg6vgqziawt5s4dj.onion/1/scm/clic If you deign to look, you'll see it's odd Common Lisp, mostly being ECL specific and having some other queer properties, such as having an unportable use of C's isatty() for a TTYP function instead of simply using INTERACTIVE-STREAM-P, as an example. I intend to have my own Gopher client written in Common Lisp, but improving this client seems like a nice way to ease back in and won't be much work. One thing that comes to mind as potentially being worthwhile, after examining clic a tad, is turning OpenBSD's pledge() and unveil() operations into a Common Lisp library, so that one could simply use this library to call these two at a high-level, ignoring things if they're not available. What do you think of this? I think I reasonably like the idea and may pursue it.
Naomi Nascimento · 2019-04-21 18:46
>>13305 >Put simply, the entire idea was to allow efficient processing of JSON by >operating solely on the textual form for as long as possible, rather than >parsing it to data structures that can then be operated on as wanted[.] If I'm understanding correctly what you're describing is a JSON tokenizer. I used a C implementation of this idea called `jsmn' in a small project awhile back, they are very fast. >One thing that comes to mind as potentially being worthwhile, after examining >clic a tad, is turning OpenBSD's pledge() and unveil() operations into a >Common Lisp library, so that one could simply use this library to call these >two at a high-level, ignoring things if they're not available. I'm unsure how many ports could benefit from this, but it seems like it would be a helpful development tool to track down unnecessary, or unexpected, sys-calls or file-system accesses, especially in larger projects.
⍕ · 2019-04-22 06:45
>>13305 I've been working on "library" on top of ncurses, in which I make my own window structure. This structure provides more functionality than standard ncurses windows. For example. It allows for scrolling and padding. More importantly though, I don't have to deal with ncurses bullsoykaf when it comes to windows, refreshing and all that. The only real window from ncurses is the screen, and I know that I can simply print, refresh, move the cursor, etc, and it won't give me problems as it does when there's more than one window involved.
Agent Jones · 2019-04-22 19:08
>>13317 Sounds very cool.
stack · 2019-04-23 07:33
Writing a (toy) assembler/compiler for an ARM Cortex microcontroller, in Shen. Make it blink an LED and call it complete.
Random · 2019-04-23 18:23
Lains, I've been bothered by something lately I found a new job developing Clojure and found that everything related to state / life-cycle-management is like kicking dead whales down the beach diseased moose wang. Component is soykaf, Mount is arbitrary, and everyone is inflicted with Java needing to manage everything and dependencies this, dependencies that. It's all an ugly mess and There Has To Be A Better Way. What are your solutions when it comes to stuff like state, IO, and complex systems? Non Clojure takes welcome as well. Related viewing material: The Language of the System - Rich Hickey https://www.youtube.com/watch?v=ROor6_NGIWU
(princ tripcode) -| · 2019-04-23 20:38
>>13305 I've spent some time today improving this clic, but the author doesn't seem to know Common Lisp very well. Rather than being relaxing, it's now more exhausting. In any case, I'll have these files up for at least a few days, in case any of you are curious to see it; the second one is the modified version with my changes: http://verisimilitudes.net/clic.lisp http://verisimilitudes.net/clic.new.lisp >>13308 >If I'm understanding correctly what you're describing is a JSON tokenizer. I used a C implementation of this idea called `jsmn' in a small project awhile back, they are very fast. My issue is that the fastest approach of mine works in the following way: Since I know the form of the particular JSON and it doesn't contain unnecessary whitespace and whatnot, I can simply SEARCH for the hardcoded key directly and then, since I know the form of the associated object, I can then very easily obtain the final result. I wanted to attempt to turn this approach into a library, but it doesn't make good sense, I suppose, to permit an approach that ignores any hierarchy of the JSON and other such things, meaning this approach doesn't work in general. Still, a JSON library that must scan over everything until it finds what it's looking for can still have advantages and it may even be within an order of magnitude of the speed of the specialized approach. The basic idea is to have a GET-MEMBER for objects and a GET-ELEMENT for vectors and it's rather obvious how this works with my previous explanation. Clearly, GET-MEMBER would simply scan over key pairs until it finds the match and GET-ELEMENT would simply be counting commas; the main complications come about from needing to handle nested objects efficiently and whatnot, which I suppose is why I've not bothered to finish this yet. Optimizations such as all results being displaced to the original string also helps. >I'm unsure how many ports could benefit from this, but it seems like it would be a helpful development tool to track down unnecessary, or unexpected, sys-calls or file-system accesses, especially in larger projects. I may or may not get around to this at some point. >>13317 How large is this library, so far? Is it publicly available yet? Also, have you taken a look at my ACUTE-TERMINAL-CONTROL and how your ideas would transfer over to it? >>13346 >What are your solutions when it comes to stuff like state, IO, and complex systems? Non Clojure takes welcome as well. State holds no special place in my mind in this way. In general, I plan ahead, try to simplify things, and design things where they can be efficient, which is different from a particular implementation being particularly efficient. As the board subtitle is: Consider; create; explore; understand; optimize.
Stallman · 2019-04-24 04:42
>>13348 >>>13346 I'm sorry lainanon but this answer is really useless I have about three wild ideas, I'm looking for more, not vaporware
Eldon Tyrell · 2019-04-24 20:32
>>13348 >The basic idea is to have a GET-MEMBER for objects and a GET-ELEMENT for >vectors and it's rather obvious how this works with my previous >explanation. Clearly, GET-MEMBER would simply scan over key pairs until it >finds the match and GET-ELEMENT would simply be counting commas; the main >complications come about from needing to handle nested objects efficiently and >whatnot, which I suppose is why I've not bothered to finish this >yet. Optimizations such as all results being displaced to the original string >also helps. I very much so misunderstood then, that is interesting.
Roy Batty · 2019-04-25 02:10
Cool article on a high-level assembler in Lisp! Check it out! https://ahefner.livejournal.com/20528.html What are your thoughts?
HELIOS · 2019-04-25 21:51
How did you lainons learn the way of CL loop macro? I do not know why but it reads very weird and feels artificial compared with simple while or do-list. I do understand the importance of enumerating without relying on side effect so really want to understand this but none of googlable explanation feels satisfactory and I end up keep returning to manual time and time again. Any useful/practical mental model to hold while reading/writing LOOP macro or historical motivation (why Guy Steele defined it this way) would be greatly appreciated.
The Plague · 2019-04-25 21:55
>>13387 especially for nested loops especially for heterogeneous data structures because I'm too stupid to come up with better solution for my game at the moment
Agent Richard Gill · 2019-04-27 01:50
>>13348 If I remember correctly, ACUTE-TERMINAL-CONTROL can't recieve input without having to also type enter (the same as if by reading using READ or READ-CHAR) I would totally use ACUTE-TERMINAL-CONTROL because it seems a lot more simpler and it feels more "right" to build on top of it.
Joey · 2019-04-27 01:52
>>13387 I read Guy Steele's book on CL. It explains the loop macro very well.
藤原純一 · 2019-04-27 01:56
>>13387 the loop macro is impressive, but falls short on alot of things >isn't extensible >no support for nested looping e.g. cant access outer loop >many more This is why I started using the ITERATE package, it's in every way superior to LOOP
Torvalds · 2019-04-27 10:46
>>13405 Would you be so kind and share it please?
Nanashi No Gombe · 2019-04-27 15:41
>>13407 It's online. The Common Lisp Language 2nd edition.
(princ tripcode) -| · 2019-04-27 19:02
>>13352 >I'm sorry lainanon but this answer is really useless >I have about three wild ideas, I'm looking for more, not vaporware Well, your vague question got a vague answer as far as I see it. >>13358 >I very much so misunderstood then, that is interesting. I'll give an example usage, as I currently see it. CL-USER> (read-line) ;This is usually an easy way to enter long strings properly and I don't want to show it twice here. "{\"id\":1821528,\"tags\":\"2018 ambiguous_gender animal_crossing anthro ape canid canine canis clothing domestic_dog donkey_kong_(character) donkey_kong_(series) eyewear female flora_fauna group hat headband headgear headwear human incineroar isabelle_(animal_crossing) jiojio_warudo konami male mammal mario mario_bros metal_gear nintendo piranha_plant plant pok\\u00e9mon pok\\u00e9mon_(species) primate shih_tzu solid_snake suit sunglasses super_smash_bros. toy_dog unconscious video_games\",\"locked_tags\":null,\"description\":\"\",\"created_at\":{\"json_class\":\"Time\",\"s\":1552971059,\"n\":48616000},\"creator_id\":136079,\"author\":\"Cane751\",\"change\":18691873,\"source\":\"http://airfortress.tumblr.com/post/180074962136/the-fam\",\"score\":11,\"fav_count\":94,\"md5\":\"4cbbf1cc0bbb38ba81d4cc3436130e0a\",\"file_size\":625152,\"file_url\":\"https://static1.e621.net/data/4c/bb/4cbbf1cc0bbb38ba81d4cc3436130e0a.png\",\"file_ext\":\"png\",\"preview_url\":\"https://static1.e621.net/data/preview/4c/bb/4cbbf1cc0bbb38ba81d4cc3436130e0a.jpg\",\"preview_width\":150,\"preview_height\":106,\"sample_url\":\"https://static1.e621.net/data/sample/4c/bb/4cbbf1cc0bbb38ba81d4cc3436130e0a.jpg\",\"sample_width\":800,\"sample_height\":567,\"rating\":\"s\",\"status\":\"active\",\"width\":1420,\"height\":1007,\"has_comments\":true,\"has_notes\":false,\"has_children\":false,\"children\":\"1708668\",\"parent_id\":null,\"artist\":[\"jiojio_warudo\"],\"sources\":[\"http://airfortress.tumblr.com/post/180074962136/the-fam\",\"https://66.media.tumblr.com/4cbbf1cc0bbb38ba81d4cc3436130e0a/tumblr_pi5778cvk01rs1maio1_1280.png\",\"https://twitter.com/ValentinSeiche/status/1062379731528663040\",\"https://pbs.twimg.com/media/Dr5UrfKWsAES5ln.jpg:orig\"]}" CL-USER> (get-member "sources" *) "[\"http://airfortress.tumblr.com/post/180074962136/the-fam\",\"https://66.media.tumblr.com/4cbbf1cc0bbb38ba81d4cc3436130e0a/tumblr_pi5778cvk01rs1maio1_1280.png\",\"https://twitter.com/ValentinSeiche/status/1062379731528663040\",\"https://pbs.twimg.com/media/Dr5UrfKWsAES5ln.jpg:orig\"]" CL-USER> (get-element 1 *) "\"https://66.media.tumblr.com/4cbbf1cc0bbb38ba81d4cc3436130e0a/tumblr_pi5778cvk01rs1maio1_1280.png\"" CL-USER> (parse-json *) "https://66.media.tumblr.com/4cbbf1cc0bbb38ba81d4cc3436130e0a/tumblr_pi5778cvk01rs1maio1_1280.png" While not nearly so efficient as a specialized method, this should still be rather efficient, I suppose. I'll find out if it's sufficient for the millions of JSON records I'll be manipulating, compared to what I've been using. >>13387 >How did you lainons learn the way of CL loop macro? I read the manual and used it a good deal. >I do not know why but it reads very weird and feels artificial compared with simple while or do-list. I suppose Lisp is similar to Forth in that it never really had its own looping mechanism, but simply took them from other languages. Chuck Moore's latest Forth simply uses tail recursion, but that's not an option with Common Lisp. In case you're wondering, DO-style loops come from FORTRAN. LOOP is heavily influenced by ALGOL languages. >I do understand the importance of enumerating without relying on side effect so really want to understand this but none of googlable explanation feels satisfactory and I end up keep returning to manual time and time again. I still need to reference the manual sometimes. It's a complex part of the language. The ITERATE library looks nice, but I never find it acceptable to have a library depend on it. If I don't want to use LOOP or it simply becomes too complex to do so, I use PROG or PROG*. >>13389 >especially for nested loops Use the NAMED keyword, which must be the first LOOP keyword and permits naming the BLOCK that contains the LOOP. >especially for heterogeneous data structures You can destructure data in FOR statements as if with DESTRUCTURING-BIND. >>13404 >If I remember correctly, ACUTE-TERMINAL-CONTROL can't recieve input without having to also type enter (the same as if by reading using READ or READ-CHAR) It can. In my programs, I simply launch the Common Lisp with a sh program first, which disables this nonsense with stty. At least one person here wanted it, though, so I have four functions, that I don't suggest you depend on, for manipulating such settings; currently, these work under Allegro, CMUCL, SBCL, and ECL: ENABLE-SYSTEM-BUFFERING DISABLE-SYSTEM-BUFFERING ENABLE-SYSTEM-ECHOING DISABLE-SYSTEM-ECHOING >I would totally use ACUTE-TERMINAL-CONTROL because it seems a lot more simpler and it feels more "right" to build on top of it. It was queer to me how I seem to be the first or among the first to build a comprehensive terminal library in Common Lisp without simply using Curses; everything that isn't just Curses seems to be both incomplete and abandoned. Anyway, I may work on it more soon; some issues involve my READ-EVENT function not working perfectly correctly when you need to be able to read the escape key and whatnot; if you do decide to use it, look at my documentation first, because there are some things, currently only (SETF PROPERTIES), that I've not solidified the behavior of yet. If you have any suggestions for more behavior, feel free to make them. Unlike the library this depends on, CL-ECMA-48, there's no real barrier to stop me from adding things with this. Also, here's the link; this is technically over an insecure connection, so you should inspect it, but you should be inspecting a library before you use it, anyway: http://verisimilitudes.net/2018-04-04
protected · 2019-04-28 03:24
>>13410 > so I have four functions, that I don't suggest you depend on Why not depend on it? > some issues involve my READ-EVENT function not working perfectly correctly > there are some things, currently only (SETF PROPERTIES), that I've not solidified the behavior of yet. I tell you what, you fix these issues, aka, have a solid library, and I"ll take it upon myself to learn your library and use it as the base for my library. >If you have any suggestions for more behavior, feel free to make them Ok, how about timed input. In ncurses, I can choose to recieve input but only for a "window" of time, e.g. for only half a second This is very useful to me and I'd love to be able to do this. If you implemented this I'd be more inclined to use ACUTE-TERMINAL-CONTROL Also, tell me how this library handles unicode, colors, and threading. For example, might there be problems if I try to do multiple things (writing to the screen, moving cursor) at the same time. There is a chance a program I'm writing will use this object, that when run on its own thread, will basically give the illusion of scrolling text, basically it would write a string to a fixed location, starting at index i of the string (initially 0), then index being 1, and then go full circle by going back to 0 and then to (length string) index. And finally, which terminal emulators will this library work with, or be most compatible with. I'm currently using urxvt, and sometimes I use the linux framebuffer terminal. There is more I want to discuss about this library, but I won't overload you with a million questions.
(princ tripcode) -| · 2019-04-28 13:20
>>13412 >Why not depend on it? The library WARNs the user about them. They're inherently unportable due to the way they work. As explained, I only have them implemented across four implementations, currently. If you read the documentation, you'll see that I believe CLISP's closest mechanism is fundamentally incompatible with mine, although I've yet to look much. >I tell you what, you fix these issues, aka, have a solid library, and I"ll take it upon myself to learn your library and use it as the base for my library. I've corrected the issue of READ-EVENT needing more than one character press to correctly read the Escape key. Interestingly, it was related to an improvement I recently made to the CURSOR function. This updated version is also now available. As for the second issue, that is merely due to my not yet being certain about what keywords I want to use to represent certain properties and whether some should be supported at all. The library is solid already. >Ok, how about timed input. >In ncurses, I can choose to recieve input but only for a "window" of time, e.g. for only half a second >This is very useful to me and I'd love to be able to do this. If you implemented this I'd be more inclined to use ACUTE-TERMINAL-CONTROL Isn't this what the standard LISTEN, SLEEP, and other such functions are for? I have a READ-EVENT and READ-EVENT-NO-HANG, so polling for a limited amount of time is possible. >Also, tell me how this library handles unicode, colors, and threading. This library is designed differently than you may think. Unicode is the responsibility of the Common Lisp implementation, and it has nothing concerning threading, either, and I don't see how my ideas for threading would integrate with it in any particular way. As for color, there are (SETF FOREGROUND) and (SETF BACKGROUND), which provide the few basic colors, along with RGB, CMY, and CMYK colors, although every terminal I've taken a look at only supports RGB. I've considered creating an ACUTE-TERMINAL-CONTROL-COLORS or ATC-COLORS package that would have names for these various RGB colors that tend to have names. >For example, might there be problems if I try to do multiple things (writing to the screen, moving cursor) at the same time. You can really only write to a stream once at any single time. >There is a chance a program I'm writing will use this object, that when run on its own thread, will basically give the illusion of scrolling text, basically it would write a string to a fixed location, starting at index i of the string (initially 0), then index being 1, and then go full circle by going back to 0 and then to (length string) index. I don't see why you'd have any issue doing this. You'd simply need to make certain you send the control codes properly. If you go into more detail, I could perhaps show you how I'd do this. >And finally, which terminal emulators will this library work with, or be most compatible with. This follows the ECMA-48 standard, for the most part, and the control functions used for these higher-level purposes should be very well-supported. >I'm currently using urxvt, and sometimes I use the linux framebuffer terminal. From my testing, the Linux kernel's framebuffer lacks support for the SCROLL UP and SCROLL DOWN control functions, so you'd have issues using my higher SCROLL function. This is a shortcoming of the framebuffer. >There is more I want to discuss about this library, but I won't overload you with a million questions. It's no issue. Feel free.
H.R. Giger · 2019-04-29 02:51
>>13410 >Well, your vague question got a vague answer as far as I see it. Allow me to simplify, then: Do you work with Clojure? Do you know Mount, Integrant, and Component? Do you think they're good ideas or huge piles of flaming trash? Do you understand what problem they're trying to solve? Do you think there's need for "life cycle management" or is it a meme which can be done elegantly in a functional manner. Who would (You) go about bringing up, for example, several threads which do several stateful things and pass data around, such as reading from/to kafka, reading and writing from a database, sending http queries, and create some in-memory cache. Let's forgo the dependencies between all of these in the meanwhile, do you have some functional idea on how to bring all of these up and running?
Davis · 2019-04-29 05:22
>>13415 >As for the second issue, that is merely due to my not yet being certain about what keywords I want to use to represent certain properties and whether some should be supported at all. Expand on this, what do these properties affect exactly? >Isn't this what the standard LISTEN, SLEEP, and other such functions are for? I have a READ-EVENT and READ-EVENT-NO-HANG, so polling for a limited amount of time is possible. I'm confused, so you're saying it's possible to recieve input for a limited amount of time, right? Because SLEEP just prevents anyting from happening for a set amout of time. So how could I read if sleep is running? if READ-EVENT / READ-EVENT-NO-HANG could have an optional parameter which sets the window of time on which to recieve the input, it'd be better imo. >Unicode is the responsibility of the Common Lisp implementation So I could use unicode then. I think I know what you mean. Unicode is always the terminal emulator and program's responsibility. If I could output some unicode as if by FORMAT in the normal terminal, I don't see why it coudldn't also show when ACUTE-TERMINAL-CONTROL is running. >I don't see how my ideas for threading would integrate with it in any particular way. What do you mean, what ideas, and how wouldn't they integrate. >I've considered creating an ACUTE-TERMINAL-CONTROL-COLORS or ATC-COLORS package that would have names for these various RGB colors that tend to have names. You should, although maybe not in a different package. The colors shoudln't be more than just about 10-20 DEFPARAMETERs, right? >You can really only write to a stream once at any single time. So would I get race conditions if I had multiple threads printing? I forgot how streams work regarding shared access. >You'd simply need to make certain you send the control codes properly. If you go into more detail, I could perhaps show you how I'd do this. What do you mean, wouldn't I just be using a function which just prints a char to the screen? I haven't started learning the library yet, so maybe I'm missing something. I guess what the object does doesn't really matter, its just what's matters is that multiple threads are running and printing strings at the same time, and I'd need to be able to do this. If mutexes are needed then so be it. >you'd have issues using my higher SCROLL function. does this imply that a "lower" function will work. >>There is more I want to discuss about this library, but I won't overload you with a million questions. >It's no issue. Feel free. When I learn more about the inner workings of the library, I will, for now I want to know what I can generally do with it.
(princ tripcode) -| · 2019-04-29 20:18
>>13418 >Do you work with Clojure? No. >Do you know Mount, Integrant, and Component? No. >Do you think they're good ideas or huge piles of flaming trash? I'd hazard a guess they're the latter. >Do you understand what problem they're trying to solve? No. >Do you think there's need for "life cycle management" or is it a meme which can be done elegantly in a functional manner. I'd similarly hazard a guess that this is a new fad. >Who would (You) go about bringing up, for example, several threads which do several stateful things and pass data around, such as reading from/to kafka, reading and writing from a database, sending http queries, and create some in-memory cache. It's my understanding Kafka is designed for massive systems, so my first thought would be to see if it was truly necessary. Assuming it's not, I'd work to have all of this happening on a single machine and I'd figure whatever is being done could be serviced by relatively few concurrent threads of execution, so I don't see the complication. >Let's forgo the dependencies between all of these in the meanwhile, do you have some functional idea on how to bring all of these up and running? I don't see what functional programming truly has to do with it. If I found myself needing a massively parallel program and Common Lisp wasn't sufficient, I'd likely learn Lisp-Flavored Erlang and use that, which is Object-Oriented in the true sense of message passing. I figure this doesn't quite answer your questions, so feel free to ask more or clarify things. >>13421 >Expand on this, what do these properties affect exactly? These concern the SELECT GRAPHIC RENDITION control function, which determines how the text appears. Codes in the thirties and forties affect the foreground and background colors, respectively. There are a total of sixty five codes, which vary from bold, italic, blinking slowly and rapidly, font selection, gothic characters, underlining and double underlining, framed, encircled, and yet others and my decision is how to divide this functionality, how to name it, and if it should be present at all. As an example, should Fraktur (Gothic) be supported, considering I'm not aware of any terminal that supports it, and which of these names, both of which are in the standard, should I choose? Am I merely abstracting only over ECMA-48 or do I want the option to transparently use other backends, which would mean I can't so closely tie this library to the ECMA-48 standard; in all likelihood, I'm choosing to merely abstract over ECMA-48, considering Windows is the only main platform that didn't, but even that now does, yet the option is still good to have. In any case, you understand my hesitation and concern, now. >I'm confused, so you're saying it's possible to recieve input for a limited amount of time, right? Yes, but I mean by using functionality provided by the COMMON-LISP package. >Because SLEEP just prevents anyting from happening for a set amout of time. >So how could I read if sleep is running? That was a mistake. I intended to mention a function such as GET-INTERNAL-REAL-TIME. You could, say, poll with LISTEN until a sufficient amount of real time has passed. >if READ-EVENT / READ-EVENT-NO-HANG could have an optional parameter which sets the window of time on which to recieve the input, it'd be better imo. I designed these functions to resemble standard functions. I would be hesitant to provide a variety of these two that accept a wait parameter. >So I could use unicode then. I think I know what you mean. Unicode is always the terminal emulator and program's responsibility. If I could output some unicode as if by FORMAT in the normal terminal, I don't see why it coudldn't also show when ACUTE-TERMINAL-CONTROL is running. You understand, yes. In particular, you would be using FORMAT and not ACUTE-TERMINAL-CONTROL for this. Unlike other libraries, there's no replacement for the standard writing functions. >What do you mean, what ideas, and how wouldn't they integrate. I mean, sans ensuring that STREAM access is exclusive, which isn't a concern of this library, that I don't see any particular concerns that are relevant to it. That is, I see nothing special this library would need to do. >You should, although maybe not in a different package. The colors shoudln't be more than just about 10-20 DEFPARAMETERs, right? There are 2^24 and so 16,777,216 RGB colors, many of which have names, which is why it would be in a different package. >So would I get race conditions if I had multiple threads printing? >I forgot how streams work regarding shared access. I suppose it's possible. There's no standard way a STREAM operates with regards to this, so it depends. >What do you mean, wouldn't I just be using a function which just prints a char to the screen? I haven't started learning the library yet, so maybe I'm missing something. If you want to write a single character to the terminal, you'd use WRITE-CHAR, which is a standard function, as mentioned earlier in this reply. If you want to write text, but you move the cursor at some other point, it would likely need to be moved back to get the effect you want. >I guess what the object does doesn't really matter, its just what's matters is that multiple threads are running and printing strings at the same time, and I'd need to be able to do this. If mutexes are needed then so be it. If you need to print at different parts of the terminal, you'd need to reposition the cursor before printing each time. >does this imply that a "lower" function will work. The higher function doesn't work with that purely due to the lower functions it uses being ignored. >When I learn more about the inner workings of the library, I will, for now I want to know what I can generally do with it. The library treats the terminal only as a STREAM and where it makes sense treats it as something you can affect by SETF. If you'd like a very brief demo of what it can do, here's a video demonstration of a program I wrote, which is the reason I created ACUTE-TERMINAL-CONTROL to begin with: http://verisimilitudes.net/mmc-demo.webm
Jet Black · 2019-04-30 04:41
>>13430 >I'd hazard a guess they're the latter. That's my impression but people seem to believe they need them >I'd similarly hazard a guess that this is a new fad. It's as old as OOP, but people are used to that way of thinking and they try to force it on anything It isn't new, probably around since at least the 80s. I believe it can all be done with lexical scoping and recursion. >massive systems I'm not talking about a personal project here buddeh, but about a massive, multi machine system. threads consuming from Kafka, munging the data, and passing it along, combining information from about three data bases to correctly process each message. We're working on simplifying it but it would still be massive. Everything has to be set up in the correct order, processes have to be set up and communicate with each other, see >erlang Clojure has channels, they allow inter process message passing >feel free to ask more or clarify things. Things are quite clear
Cypher · 2019-04-30 18:22
>>12185 Really enjoying the lisp integration within emacs. Programming in Clojure and CL is a breeze! I do have a general functional programming question, though. I'm attempting to solve the problem in the image (printSquares) using Clojure (the problem was originally in C++, where we could use references to build up our solution). Here's what I have (defn print-squares-helper [target min so-far ] (defn square-sub [x] (- target (* x x))) (cond ;; base case, sum has reached `n` (= target 0) (println so-far) (< target 0) nil :else (doseq [curr (range min (+ 1 (Math/sqrt target)))] ;; Debug print. ;; (println "Target: " target "\n\t Set: " so-far "\n\t Curr: " curr "\n\t Next: " (square-sub curr)) (print-squares-helper (- target (* curr curr)) ;;(- target (* curr curr)) Works ;; (square-sub curr); Doesn't work (+ curr 1) (conj so-far curr ))))) I have two questions: 1) If I were to replace the line (- target (* curr curr)) with a call to the function (square-sub curr) , I would get wildly different behavior (almost as if we assign target the value of the function call). Why is this? I know do-seq allows for side-effects, but is this normal behavior? 2) Let's say the parameters of the problem changed and that I would need to return a set of lists, where each list is the list of values that give you the correct sum. How would I approach this now? The overall algorithm wouldn't change, but I would need some way of keeping track of all the successful calls to (print-squares-helper) . Clojure isn't really built for setting and modifying local values (since there is no set-f), so Im' a bit lost how you would build a collection of values, using recursive backtracking, while also not modifying any state. Sorry for the long post, but I've been mulling about this for a while.
Roy Batty · 2019-04-30 18:49
>>13441 What packages are you using to integrate CL and Clojure with emacs? I know a lot of people use slime and cider.
Hagbard Celine · 2019-04-30 19:21
>>13441 Anon, why are you defn-ing inside a defn? I think it works (maybe?) but it's better to close over a value with letfn maybe that would help with 1). probably causing the fuarrrkery as for 2), the problem starts with you printing the result in the end, instead of accumulating it, think along those lines. Also, in clojure you can define multi arity functions, so no need for helpers anymore For a hint of where your solution soykaf the bed, I traced both versions. Pic related is where things got funny
Random · 2019-04-30 19:33
>>13441 >>13443 I reimplemented your solution in a bit more clojure-y way but I didn't do it elegantly at all. You're picking up lots of nils you don't want to keep and need to discard them My way wasn't really good, probably a reduce checking if what returned as a nil or a set... Clojure (defn find-squares ([target] (find-squares target 0 #{} #{})) ([target min so-far found] (letfn [(square-sub [x] (- target (* x x)))] (cond ;; base case, sum has reached `n` (= target 0) (conj found so-far) (< target 0) nil :else (reduce clojure.set/union (flatten (remove nil? (for [curr (range min (+ 1 (Math/sqrt target)))] (find-squares (square-sub curr) (+ curr 1) (conj so-far curr) found)))))))))
Zuse · 2019-04-30 19:37
>>13444 Here, I'm happier with this solution Clojure (defn find-squares ([target] (set (find-squares target 0 #{} #{}))) ([target min so-far found] (letfn [(square-sub [x] (- target (* x x)))] (cond ;; base case, sum has reached `n` (= target 0) (conj found so-far) (< target 0) nil :else (mapcat #(find-squares (square-sub %) (inc %) (conj so-far %) found) (range min (+ 1 (Math/sqrt target))))))))
Leto Atreides I · 2019-04-30 20:13
>>13442 Right on the money! I use slime (for CL) + cider (Clojure). My one complaint is that when there's a runtime error in Cider, I haven't been able to find a way to the actual line in the program that leads to the run-time error (just the function that raised the error), so I need to do some investigative work and see where I'm accidentally passing a long to a set or something like that. >>13443 >Why are you defn'ing within a def'n? I've seen this more in things like Scheme. Essentially, I'm trying to do a form of encapsulation; other functions don't *need* to know how I'm doing the implementation of square-sub, so it's private to the outermost function. >>13444 >>13445 Okay... I think I'm sort-of understanding what's going on. >Muti-Arity functions I genuinely didn't know Clojure could do this. That's so cool! I really should get on *Clojure for the Brave and True* and/or *Practical Clojure*. >Solution. Most of the code you wrote makes sense (specifically the `mapcat` function)., but I'm still a little confused as to how `letfn` works. From the link in the documentation (here: https://clojuredocs.org/clojure.core/letfn) I'm guessing it's a way of defining multiple functions at once? If Im' being honest, I'm still not entirely sure why letfn fixes the clojure issue I was getting with the original use of square-sub , but I'm happy to just browse this code and learn what I can from it at the moment. Thanks for all the help, everyone!
Project 2501 · 2019-05-01 02:39
>>13446 I had a feeling you got the idea to defn inside of defn from scheme It's a good idea but done differently in clojure, and I may have a notion as to why it acted weird only as of yesterday (go watch Rich Hicky's Clojure for Lisp Programmers) Clojure *is* a lisp-1, so it's lexically scoped and you'd expect defn's to behave like in scheme, but somehow I'm unconvinced because clojure doesn't assign defns to symbols, but to vars, and the symbols are resolved to the vars by the reader. I have no idea what's going on with the var's root inside the scope of a function. >letfn okay, in short, there aren't defn's in clojure. defn is a macro for (def symbol (fn...)). fn returns a function object and def binds it in a namespace. To do lexical binding you can use let, like you know from scheme (every let in clojure is like let* in scheme), i.e. (let [a 1 foo (fn ...)] expr1 ... exprN) letfn is just a macro which expands to (letfn [(name [args] body)] *exprs) to (let [name (fn name [args] body)] *exprs) and yes, fn can optionally take a name as an argument to make it recursive If you want to go through the steps I went in rewriting your solution, go back to my first code snippet and raise the `for` loop up to the top of the :else condition (meaning delete the remove, flatten, reduce) and see what you get. doseq is for side effects, for, map and loop are for saving results
Cereal Killer · 2019-05-01 16:39
>>13430 >or do I want the option to transparently use other backends Would using other backends help with the issue of the linux framebuffer terminal not being compatible? As for gothic, if it isn't supported, then don't include it. I haven't read the standard yet, or other standards, so I wouldn't know if ECMA-48 is encompassing of other standard's behavior/abilities or if it's lacking. >you would be using FORMAT and not ACUTE-TERMINAL-CONTROL for this >you'd use WRITE-CHAR, which is a standard function >The library treats the terminal only as a STREAM Now I kind of understand how it's all designed. I have to read the documentation and standard for more details though. This design of just operating on a stream is very nice as we can just use standard CL functions. My only question for now is what control functions should I mostly care about? I saw in your rebuttal article, that you used the REPEAT control function a couple of times, is this going to be a frequent control function I'd have to use?
(princ tripcode) -| · 2019-05-02 08:27
>>13434 >Things are quite clear It's regrettable I wasn't able to answer your question better, then. >>13450 >Would using other backends help with the issue of the linux framebuffer terminal not being compatible? No; the Linux kernel's framebuffer terminal understands some ECMA-48 control functions, along with other things, but it's not a drastically different thing. It simply fails to support some very basic control functions, from my understanding. >As for gothic, if it isn't supported, then don't include it. See, my issue with this is that I don't want to write a library based on whatever is currently supported; I want to write the ideal. What I'll likely end up doing is documenting a version of my (SETF PROPERTIES) that supports a very small subset of the properties and ignores everything that poses issues; so, I'd have bold, italics, underline, but not the two varieties of blinking text, double underlines, and you get the idea. I may have a (SETF FONT), but I'd need to think on that design a tad first. >I haven't read the standard yet, or other standards, so I wouldn't know if ECMA-48 is encompassing of other standard's behavior/abilities or if it's lacking. I can safely only send ECMA-48 control functions, ignoring this termcap and terminfo nonsense, because ECMA-48 is the only standard you're really going to see anywhere, in practice. Every terminal emulator you regularly use under a UNIX system is going to understand it. >Now I kind of understand how it's all designed. I have to read the documentation and standard for more details though. Do. The ACUTE-TERMINAL-CONTROL documentation explains the ECMA-48 control functions used to achieve the effects. >This design of just operating on a stream is very nice as we can just use standard CL functions. That's the very point, yes. This library doesn't get in the way. >My only question for now is what control functions should I mostly care about? For you, don't care about any of them; instead, just focus on the abstraction I've built over them. If you mean you want to learn for your own purposes, the CL-ECMA-48 documentation has a link to the standard document you can read, which is a rather light read. >I saw in your rebuttal article, that you used the REPEAT control function a couple of times, is this going to be a frequent control function I'd have to use? I really should rewrite that article, but that's the case with many of my articles. I really just wanted to show how much better my library is than any of that Ncurses garbage; if you read the article I rebut, he's got a color pair macro and so much other nonsense; it's completely unnecessary and it misleads people into thinking it's important, rather than the echoes of decades of poor decisions. I only used the REPEAT control function, which isn't abstracted in ACUTE-TERMINAL-CONTROL, to show how it's rather easy to do all of this. There's no need for all of that Ncurses nonsense.
Dujour · 2019-05-02 21:02
>>13458 >(SETF FONT) omg please, changing fonts on the fly seems a good power to have. >ECMA-48 is the only standard you're really going to see anywhere This fact is more the reason you should only stay with ECMA-48 Ok I've read some parts of the documentation and I've got more questions: Is the origin '(1 . 1) or '(0 . 0) ? For the SCROLL function, how does it exactly work? Let's say I have a character at the left margin of terminal, and I SCROLL left, would it bring the character to (y - 1, rightmost x)? I want to know what fundamentally is happening. I know we're using streams, but say I want to "capture" (for storage and later retrieval) what is viewable to the user, or the entire stream itself: will it also capture the colors? For READ-EVENT, are mouse events "enabled" by default? Can I somehow configure READ-EVENT, through CL-ECMA-48, to not return mouse events, but only keyboard events? If I disable system buffering, what will happen when I read-char? Or should I just use read-event/no-hang only? If I run ENABLE-SYSTEM-BUFFERING, DISABLE-SYSTEM-BUFFERING in order, would standard reading functions behave as they normally would? Also, in practice, when would cursor really return NIL? I'm going to write a sample program and test it out soon.
dictionary · 2019-05-02 21:28
>>13470 Oh yeah, what exactly do you type for launching programs? I know it's in an sh file, and something stty.
(princ tripcode) -| · 2019-05-02 22:54
>>13470 >omg please, changing fonts on the fly seems a good power to have. The main issue is that there are ten fonts defined, zero through nine, but most terminals don't seem to do anything with these by default. Still, it will likely be exposed as (SETF (FONT) 9) , as an example usage. >Is the origin '(1 . 1) or '(0 . 0) ? The origin is 1,1 and so the former. >For the SCROLL function, how does it exactly work? >Let's say I have a character at the left margin of terminal, and I SCROLL left, would it bring the character to (y - 1, rightmost x)? If you SCROLL LEFT, the contents of the terminal seem to shift to the left, leaving space at the right margin; the leftmost contents would be discarded. >I know we're using streams, but say I want to "capture" (for storage and later retrieval) what is viewable to the user, or the entire stream itself: will it also capture the colors? The control functions are sent to the STREAM, so yes. I recommend using a BROADCAST-STREAM for doing this. >For READ-EVENT, are mouse events "enabled" by default? It doesn't do anything to change this, but it would depend on what the terminal settings already are. >Can I somehow configure READ-EVENT, through CL-ECMA-48, to not return mouse events, but only keyboard events? You'd be sending terminal-specific sequences. I prefer to avoid treating anything such as this as able to be configured, so my advice is to simply always handle the possibility of a mouse event, such as by discarding such a result. >If I disable system buffering, what will happen when I read-char? That really depends on the implementation, but in practicality it will cause READ-CHAR to accept a single keypress. >Or should I just use read-event/no-hang only? You should only use READ-EVENT and READ-EVENT-NO-HANG if you're interested in terminal events more complex than characters. It's completely optional. >If I run ENABLE-SYSTEM-BUFFERING, DISABLE-SYSTEM-BUFFERING in order, would standard reading functions behave as they normally would? That really depends on the implementation, but in practicality it will cause them to behave differently. As an example, many implementations rely on the system buffering to provide line editing and provide none of their own, so a backspace would be part of the line, rather than removing a character. >Also, in practice, when would cursor really return NIL? In practice, it will return NIL if you use it with a STREAM that isn't a terminal device or with a terminal device that takes more than 0.45 seconds to send any part of the response. The alternative was waiting indefinitely, which I didn't like. >I'm going to write a sample program and test it out soon. I'm glad. I anticipate looking over it. >>13471 >Oh yeah, what exactly do you type for launching programs? You may find that here: http://verisimilitudes.net/mmc-chip8 You don't need to concern yourself with restoring the previous terminal state, so simply use stty raw -echo . While again I don't recommend using them, you can use DISABLE-SYSTEM-BUFFERING and DISABLE-SYSTEM-ECHOING for this, although things aren't perfectly the same on my system with regards to the buffering, which I'm still fiddling with every now and then.
The Fin · 2019-05-02 23:47
>>13472 >the leftmost contents would be discarded so if I scroll right, then the leftmost vertical line would be empty? >my advice is to simply always handle the possibility of a mouse event yeah I thought back after I posted, it'd make more sense to just discard it Oh yeah, before I start writing a program. Have you been able to interactively play around with ACUTE-TERMINAL-CONTROL? Like, I want to have separate window where I stty raw -echo; sbcl --load program.lisp, but send commands through another window, preferably an emacs slime buffer. And also, is resizing an event? Is resizing possible? to be honest, it's really cool how meta keys are able to be part of an event e.g. (:control #\a), but (:shift #\a) is the same as A, and I assume that the latter is sent in READ-EVENT/NO-HANG ?
car · 2019-05-02 23:49
>>13473 *scroll right after scrolling left
(princ tripcode) -| · 2019-05-03 00:23
>>13473 >so if I scroll right, then the leftmost vertical line would be empty? Yes. Perhaps you should simply experiment with it, to gain a firsthand understanding. >Oh yeah, before I start writing a program. >Have you been able to interactively play around with ACUTE-TERMINAL-CONTROL? I'd play with it in a session that simply had the terminal settings as I wanted, so the output was mangled, but it worked for my purposes. >Like, I want to have separate window where I stty raw -echo; sbcl --load program.lisp, but send commands through another window, preferably an emacs slime buffer. You could do that. I've never bothered to use Slime in this way, since I don't care enough. >And also, is resizing an event? UNIX exposes this as a SIGWINCH signal, the default handler of which ignores it, and there's no portable way to respond to UNIX signals. >Is resizing possible? I'll give an example of how I handled it, with that MMC program I linked a demo of earlier. The thought of having an action purely for redrawing the screen offended by sense of aesthetics; I found the very idea disgusting. There is an action that permits the user to jump around the address space that this program of mine manipulates, for convenient manipulation; an unoptimized and so realistic implementation of this action simply redraws the entire screen, rather than trying to optimize the drawing. I decided this would nicely fulfill the role of a redrawing command without making an explicit such command, so that's its dual use; to handle terminal size changes, I simply have this action collect the dimensions each time, using the previous dimensions in the case of failure, which shouldn't happen if I successfully got them once before, but it's proper to always handle potential failure. >to be honest, it's really cool how meta keys are able to be part of an event e.g. (:control #\a), but (:shift #\a) is the same as A, and I assume that the latter is sent in READ-EVENT/NO-HANG ? You should look at the documentation for a list of these events that are represented. Control and shift simply send normal characters, but I may later integrate :META key support; I've not done so yet and want to avoid keys that aren't sufficiently common. I'll likely represent the cursor keys next, with :CURSOR-UP, :CURSOR-DOWN, :CURSOR-LEFT, and :CURSOR-RIGHT and I'm considering having them CONSed with their argument, as I do with :FUNCTION, but I may do this and simply send only the symbols in the common case of one being the argument, which I believe is all most terminals will ever send anyway.
Iverson · 2019-05-03 02:13
>>13475 Have you considered making (CURSOR) always write to the same cons, it'd be useful to do this (decf (cdr (cursor))) although, I guess if u made it a function, you already wanted it to output unique cons Thinks are looking up, I'm gonna test some more with READ-EVENT, SCROLL, and SOUND >you should look up documentation in the standard? >im considering having them consed with their argument I assume their argument tells how many to go "up" or "down" or whatever, how would one even input such a thing in the keyboard
() · 2019-05-03 14:26
>>13410 In case you're curious how this would be done in jsmn, basically all it does is lex the json into a array of structs with a token type of either object, array, string, or primitive, a start and end position and a number of child tokens. So if your data has a static form you can do something like search for the nth token of type in the array and then make fixed jumps within the array to the elements of interest. Your solution would be faster and more correct though.
Ivan Horvat · 2019-05-04 16:21
also, lisp, I know you are in the lainchan server but would you consider ever being in the #lisp channel in freenode?
(princ tripcode) -| · 2019-05-04 19:27
>>13476 >Have you considered making (CURSOR) always write to the same cons, it'd be useful to do this >(decf (cdr (cursor))) >although, I guess if u made it a function, you already wanted it to output unique cons I'd prefer an interface that doesn't CONS, but that wouldn't be particularly elegant. Also, you must use (SETF CURSOR) to change the cursor's position. On that note, (SETF CURSOR) requiring a CONS is also unfortunate, but that's generally not much of an issue, since it's easier to reuse a CONS for that and likely also easier for an implementation to optimize the CONS usage. >Thinks are looking up, I'm gonna test some more with READ-EVENT, SCROLL, and SOUND Alright. Let me know how that goes for you. >in the standard? I meant my ACUTE-TERMINAL-CONTROL documentation. >I assume their argument tells how many to go "up" or "down" or whatever, how would one even input such a thing in the keyboard What the terminal does is send the same control functions used to move the cursor, but as input. Since these accept an argument, it seems proper to also have the interface reflect this, but if I special case an argument of one, I doubt I'd ever really see anything else. >>13477 That's interesting. I may look more into this jsmn, but if I ever do it will likely be far in the future, once I've finished JSON-SUCKER. >>13478 >also, lisp, I know you are in the lainchan server but would you consider ever being in the #lisp channel in freenode? The only reason I was on Freenode, which I dislike because it bans Tor nodes that haven't already identified themselves, to start with was so I could ask the Quicklisp maintainer to add my libraries, but he refused in a very rude way, to put it lightly. I was in #lisp again a tad, recently, under the name ``verisimilitude'', but I don't rightly care for some of the people in that channel and don't intend to return except to let one fellow know when I finish something, since I told him I would. I hardly care for IRC as it is and Freenode's inconvenient to connect to compared to Lainchan's IRC. The most alluring channel there is #ada, since Lainchan almost entirely lacks Ada discussion, but I haven't been in there recently, either. For circumstances such as this, I greatly appreciate that Common Lisp et al. are standardized languages and how any IRC channel, message board, Discord nonsense, or other drivel can never be official in any sense of the word and I can freely ignore it and discuss things elsewhere, perhaps under a different medium. In sum, I never used #lisp until recently and I don't quite care for it.
SHODAN · 2019-05-05 00:58
Anyone use StumpWM? How is it?
Haruyoshi · 2019-05-05 01:06
>>13481 I so want to try that. I want to eventually use everything Common Lisp. I tried it for a bit, and I didn't know emacs then so I was confused by how the workflow was supposed to be. I plan to give another shot eventually. Also, there's a demo online.
Bobby Newmark · 2019-05-05 17:41
>>12185 I'm going through the L99 (Lisp, 99 Problems) and am having a bit of trouble seeing if I'm doing some of the questions correctly. Is it for, in a recursive function, to build up your answer by cons'ing to the front as you traverse the input list, then simply reversing it at the end? I feel like there could be faster solutions, but at the same time, that would mean inserting at the back of a list, which is O(n). Here's an example: ;; Problem 17 - Split a list into two parts: ;; 1) The length of the first part is given. ;; 2) The rest of the list. (defun prob-17 (input-list len) (prob-17-helper input-list len '())) (defun prob-17-helper (input-list len so-far) (cond ((null input-list) nil) ((zerop len) (list (reverse so-far) input-list)) (t (prob-17-helper (rest input-list) (- len 1) (cons (first input-list) so-far)))))
Pris · 2019-05-05 17:43
>>13487 Sorry. Mean to say "Is it normal, in a recursive function..."
Chan Siu Ming · 2019-05-05 19:26
>>13487 Yeah, if you want O(1) memory, then the consing would result in a list which you'd need to reverse at the end. But you can do something like (cons (my-function ...)) where my-function is the function you're defining, i.e. its recursive. In this case, memory won't be O(1) but the result will be in order and you won't need to reverse the list at the end. In my opinion, I'd do the second option, because if you're gonna need to reverse it at the end, might as well do it the second way, and it more clean, no need for explicit calling of reverse everytime you need my-function's result.
Dr. X · 2019-05-05 19:26
>>13489 fuarrrk, I meant (cons some-element (my-function ...))
Faye Valentine · 2019-05-05 19:38
>>13487 I'll tell you about a weird thing I found out about. In Scheme, you can use continuation passing style to essentially have a result which wouldn't need reverse, it's really weird, and lambdas play a huge part. When I saw this code, it blew my mind, I couldn't think, my brain was too overwhelmed. The book is The Little Schemer, and for most of the book, you can easily understand what's going on, but in the last chapters, specially in the "Lambda the Ultimate" chapter, oh boy, you're going to have a hard time. Pic related.
Nell · 2019-05-07 18:51
>>13481 >Anyone use StumpWM? How is it? It's fine. I like having an REPL available in two keystrokes and it resembles Emacs in how easy it is to figure out how to do new things. Just recently I experienced this odd bug that required me to kill it, though, because it stopped recognizing my command key prefix. >>13487 >Is it for, in a recursive function, to build up your answer by cons'ing to the front as you traverse the input list, then simply reversing it at the end? You can do that, but it can be inefficient. If you don't need the elements in any particular order, don't change it at all. >I feel like there could be faster solutions, but at the same time, that would mean inserting at the back of a list, which is O(n). Inserting in a linked list is O(1) if you already have the node you want to insert after. All you need to do to build a list in order efficiently is to maintain a link to the end of the list, so you can insert at the end in constant time.
Gyula Kovacs · 2019-05-09 16:18
Hi there Lainons. I have a clojurescript question, maybe someone here is able to give me some help. Bear in mind, I have 0 asynchronous or javascript programming experience. I have hacked some Clojure for webscrapping and some scientific programming, but that is the extent of my experience. I am trying to connect to a microsoft sql server (customer is microsoft fanboy) via clojurescript. I am using javascript's mssql package[1]. I have managed to access to the database without issue. But I need a function that would query the database and return the output. (ns fig-test.core (:use-macros [cljs.core.async.macros :only [go go-loop alt!]]) (:require [cljs.core.async :refer [chan put! take! >! <! buffer dropping-buffer sliding-buffer timeout close! alts!]] [promesa.core :as p] ["mssql" :as mssql])) (defrecord ChatFAQ [faq-map]) (def output (ChatFAQ. nil)) (def config-options (clj->js {:encript true})) (def config (clj->js {:user "node" :password "****" :server "*****" :database "*****" :options config-options})) (def pool (mssql/ConnectionPool. config)) (def request (mssql/Request. pool)) (def query "select * from ChatFAQ") (defn query-helper [err result] (if err (console.log err) (let [clj-result (js->clj (.-recordset result) :keywordize-keys true)] (println output) (set! output (assoc output :faq-map clj-result)) (println output)))) (.connect pool) (.batch request "select * from ChatFAQ" query-helper) (.close pool) I know, some things might not be very idiomatic, like mutation and whatnot, and I am happy to read any critizism you have on that issue. But my real problem is: last 3 lines. They work fine when I C-x C-e line by line in emacs. But obviously, when i put them in a do in order to execute inside a funcion, when the .batch function is called, the connection is not fully open. I have tried several approaches. One is using the Promesa library[2]. But there seems to be an issue with the alet macro in my installation p/alet seems to be undefined. I will keep digging in here. Use of undeclared Var promesa.core/alet at line 2 <cljs repl> I have also tried to use core.async (go (.connect pool) (println "opening") (<! (timeout 30000)) (println "opened?") (.batch request "select * from ChatFAQ" query-helper) (.close pool)) But this does not seem to work. the output struct does not get updated. Any ideas how can I solve this? Any comments on my code, even when not to solve my problem? Thanks a lot lains. [1] https://www.npmjs.com/package/mssql#batch-batch-callback [2] https://funcool.github.io/promesa/latest/#asyncawait-syntax
The Fin · 2019-05-10 01:39
>>13496 >maintain a link to the end of the list to be honest I liked how guile has a module for this, called "q", and it uses a cons to store the list in the car, and the reference to the last cons cell in the list as the cdr I ended up writing a small library that provides the same in Common Lisp since it's so useful to be able to O(1) insert.
Cowboy · 2019-05-10 03:57
>>13515 Anon, I don't want to be harsh but this is a mess. I only worked with Clojure, not cljs, but, but you have too many defs and mutable things in your code. Everything you def-ed can be scoped in a let statement Don't modify the output variable, when working in the REPL then it makes sense to def something to be the output of the request. If batch doesn't return anything which is why you needed to use a callback function which modifies a state, this is when you use a channel or an atom Also, I don't think you need a record here.
H.R. Giger · 2019-05-10 06:31
>>13520 Not harsh at all. Thank you for your comment. Any feedback is a gift. I will tidy things up when i have a working solution. I gave a try to a channel. I will post the thing when i get to work. But when i put everything into a function, the cannel was not mutated. I will try an atom.
Nobody important · 2019-05-10 08:01
>>13520 >>13524 This was my approach with chans, but it does not matter how long I make the thing wait, the .batch call always yields #object[ConnectionError ConnectionError: Connection not yet open.] (defn query-database-helper [query-string] (let [output (chan)] (go (.connect pool) (<! (timeout 60000)) (println "will it connect?") (.batch request query-string #(if %1 (println %1) (put! output (.-recordset %2)))) (.close pool)) output)) (query-database-helper query) (defn query-database [query-string] (def output (query-database-helper query-string)) (take! output #(def rrr %)) rrr) Let me just say again, if I call the go block calls one by one in Emacs, everything work. I am really baffled about this, cause it does not take me more than 10 seconds to go from the opening line to querying line. So I dont get why waiting does not work.
Batou · 2019-05-10 12:27
>>13525 I'm not sure how go is implemented in cljs but in clj it's around a connection pool, do you have async/thread in cljs? give it a whirl Also, never def inside a function, you're biding the names in the namespace scope. Use let-s instead. Pass the output channel as an argument to the query function, and put into it with >!!
Dozer · 2019-05-10 13:52
>>13527 Yup, that worked, cleaner code version (ns fig-test.core (:use-macros [cljs.core.async.macros :only [go]]) (:require [cljs.core.async :refer [chan put! take! >! <! timeout]] ["mssql" :as mssql])) (def config-options (clj->js {:encript true})) (def config (clj->js {:user "node" :password "****" :server "*****" :database "*****" :options config-options})) (def output (chan)) (def query-string "select * from ChatFAQ") (defn query-database [output-chan config query-string] (let [pool (mssql/ConnectionPool. config)] (go (.connect pool) (while (not (.-_connected pool)) (<! (timeout 3000))) (prn (str "connected? " (.-_connected pool))) (<! (timeout 1000) (.batch (mssql/Request. pool) query-string #(if %1 (println %1) (go (println (.-recordset %2)) (>! output-chan (.-recordset %2)))))) (println "batched") (.close pool) (println "done and out")))) That works. Thanks a lot for the comment. >!! is not available for clojurescript. but this seems to work. Now I only need to figure out how to get value out. But I am still happy to take any critizism on my code.
BloodCat · 2019-05-10 14:33
>>13528 Outside query-database you can take from the channel inside a go block, something like Clojure (let [data (go (<! out-chan))] *exprs) I don't envy you having to write interop, it's a headache. Since you're creating a pool, connecting and closing and it's unrelated to the logic of what you're doing, I recommend writing in the future a macro to abstract it, something like Clojure (defmacro with-pool [pool & body] `(.connect ~pool) ~@body `(.close pool)) And maybe something which would scope the pool from the config as well, sort of with-cfg-pool, same as with-pool but also creates one. You want to keep the logic of pool creation, handling and closing separate from program logic.
car · 2019-05-14 08:31
>>13529 I am giving some thought to your macro proposal. I am not sure a macro is appropriate here, I think I can do with a function.
Cereal Killer · 2019-05-23 06:05
Hey lisp, sorry I've been busy with school. I've gotten to test ATC, and this is what I have to say. I forgot what you said about resizing, but if it would be possible, please make it possible (and also a resizing event) dimensions seem to not change after the terminal has been resized. Also, events like (:control #\) and :up :down :left, etc, would be much appreciated Also, I've tested scroll and it seems to only scroll up and down, haven't seen :left and :right work As for the cursor itself in the screen, would it be possible to have a function(s) which disables/enables it showing on the screen?
swap · 2019-05-23 06:07
>>13694 I take back the dimensions comment, dimensions changed after a big resize happened.
Hououin Kyouma · 2019-05-23 06:09
>>13695 and I forgot resize isn't an event, so it wasn't registering in the test code, hence no update, sorry
Meddler · 2019-05-23 06:20
>>13694 also, how come read-line doesn't do anything is it because disable-system-buffering breaks it? I don't mind just using read-char though
Judge Fang · 2019-05-23 06:31
>>13694 yeah if I had to ask of something that had to be in atc, it would resizing events, and (:control char) / (:alt char) / (:meta char) and option to have cursor not show. I don't think I'd use scroll since you said framebuffer terminals dont suppor it. I think that functionality would complete all I need from atc. (although maybe other things might arise in future)
(princ tripcode) -| · 2019-05-23 22:26
>>13694 >Hey lisp, sorry I've been busy with school. There's no need to apologize. The only reason I don't use the same name here as on the IRC is because there's no concept of a tripcode in IRC and so the name doesn't work there. >Also, events like (:control #\) and :up :down :left, etc, would be much appreciated I'll probably end up adding some of those. I don't know if I'll add control support for all characters, nor can I. >Also, I've tested scroll and it seems to only scroll up and down, haven't seen :left and :right work That's wholly dependent on the terminal. You can test some of the more elaborate functionality in xterm, as one example. >As for the cursor itself in the screen, would it be possible to have a function(s) which disables/enables it showing on the screen? Yes. I don't provide one, however, and don't know if I will. It relies on nonstandard control functions. >>13697 >also, how come read-line doesn't do anything It depends on how you're using it; I don't know. >is it because disable-system-buffering breaks it? It can; it depends on the implementation and likely will. >I don't mind just using read-char though If you don't need system buffered input, you need to write your own, yes. >>13698 >yeah if I had to ask of something that had to be in atc, it would resizing events I can't add those in standard Common Lisp and this is something I don't believe I'll ever actually add. I only begrudgingly added the echoing and system buffering functions in part because they were relatively easy, whereas UNIX signals are very different. >I don't think I'd use scroll since you said framebuffer terminals dont suppor it. I told you one doesn't seem to. I still use the scrolling control functions, because if a terminal doesn't support basic control functions I don't care if it works. If you wanted to be perfectly portable across any terminal you come across, you'd effectively be limited to arbitrary cursor positioning and that's it. I find that unacceptable, since I must use the terminal due to a lack of any decent GUI functionality. On that note, if any of you have written graphical Common Lisp programs with GTK, Qt, tk, or something else, do let me know how it was. I've found no good solution.
Mario Rossi · 2019-05-23 22:55
>>13707 So you've said you probably won't add resizing, (:control char), (:meta char), and (:alt char) events. How would I go about doing it myself, I have no idea. If you could point me in the right direction so I can do it myself. I know you think that adding many of the things I have talked about would make atc much non-portable because it adds dependency on OS and non-standard control functions. For me, I'd be fine because my program would be linux only and I don't mind just using sbcl, but I understand why you aren't fine with that. Hence if I could somehow make this non-portable behavior in another package for my own usage, it'd be better. I just don't know how to do it, you are obviously much better than I when it comes to understanding stuff like that.
Switch · 2019-05-23 22:57
>>13708 Yeah I'm thinking of calling it, non-portable-terminal-control. nptc
(princ tripcode) -| · 2019-05-24 06:09
>>13708 >>13709 >So you've said you probably won't add resizing, (:control char), (:meta char), and (:alt char) events. No. I'm not opposed to adding support for the Meta (Alt) key in some way, once I start working on that. The issue with control characters is the ambiguity of sorts. From this conversation, I believe you're unaware of some issues with this, so I'll explain them with a simple example: the Tab character in ASCII has a character code of nine; it's ambiguous as to whether you typed control with the i key or only the tab key; which would you rather receive when reading an event, #\Tab or (:CONTROL . #\i)? >How would I go about doing it myself, I have no idea. If you could point me in the right direction so I can do it myself. I'd tell you to read the standards again, but we've gone into territory where those don't apply much. You could look at the xterm documentation, I suppose, but I don't much care for it; you would go there if you wanted to find the particular control sequence to manipulate the cursor, say. I'll save you the effort and show you how to enable and disable the cursor in xterm. Now, xterm is poorly documented, so you must visit this webpage to get the list of silly sequences it supports: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html Now, the ECMA-48 standard has some provisions for private extensions, which xterm makes heavy use of. We can see that we can adjust this with the SET MODE and RESET MODE control functions with parameters of ? and 25. Here's how to do that with CL-ECMA-48: (ecma-48:reset-mode '(#\? 25)) ;Disable showing the cursor. (ecma-48:set-mode '(#\? 25)) ;Enable showing the cursor. >I know you think that adding many of the things I have talked about would make atc much non-portable because it adds dependency on OS and non-standard control functions. Yes. I also dislike them. >For me, I'd be fine because my program would be linux only and I don't mind just using sbcl, but I understand why you aren't fine with that. I believe one should always try to write portable Common Lisp. >I just don't know how to do it, you are obviously much better than I when it comes to understanding stuff like that. I was thinking about your request for resizing events earlier and what I believe is the proper way to do that. You should seek out a library that allows registering signal handlers and then simply have code that will collect the new dimensions for a SIGWINCH. With this approach, you get what you want, without muddying either library. >Yeah I'm thinking of calling it, non-portable-terminal-control. nptc I can't tell you I like the name. In any case, I can't stop you from adding onto my software, nor do I really want to considering the license, but I do believe it's misguided and I don't believe you'll get very far with it since you admit this isn't something you're particularly knowledgeable of. You may be interested to know there's one fellow building a toolkit of some sort on ACUTE-TERMINAL-CONTROL, although he's not yet shared his work. I'd also want to remind you that anything built on ACUTE-TERMINAL-CONTROL or CL-ECMA-48 would also be AGPLv3, but you of course know this.
Nameless · 2019-05-24 18:47
>>13712 >The issue with control characters is the ambiguity of sorts. >would you rather receive when reading an event, #\Tab or (:CONTROL . #\i) Is there a lot of cases (aproximately how many) like this where either value could be returned? >I'll save you the effort and show you how to enable and disable the cursor in xterm. I assume most terminal emulators follow in xterm's footsteps, so would that reset-mode and set-mode work on most terminal emulators? >Yes. I also dislike them. >I believe one should always try to write portable Common Lisp. >I can't tell you I like the name. In any case, I can't stop you from adding onto my software, nor do I really want to considering the license, but I do believe it's misguided and I don't believe you'll get very far with it since you admit this isn't something you're particularly knowledgeable of. I can feel your disdain to what I'm trying to do. I of course look up to you, so I thought of renaming the library to linux-terminal-control, and making the library more portable, but within the Linux environment. (i.e. support more terminal emulators and whatnot) I looked through atc's code though, and I felt discouraged after looking at it. The complexity alone for xterm's idiosyncracies, and the fact that I would also have to try to make library work with Unix signals, multiple implementations and terminal emulators, meant that it would be way more complex than the already complex code found in ATC. I'm sure you'll be happy to know I won't entertain of even trying to make this library a thing. The fact is, I'm too dumb to code at your level. I'll just stay with ATC and try to hack a solution for resizing (e.g. use read-event-no-hang and look at dimensions). I have a question though, alot of code (like in read-event) is trying to work with xterm, but I'm not sure if you're just handling xterm or handling it along with other terminals at the same time. My guess is the latter, since your philosophy is portability, but I want to hear from you. Thanks.
(princ tripcode) -| · 2019-05-24 20:41
>>13720 >Is there a lot of cases (aproximately how many) like this where either value could be returned? That would be every case. So, it becomes an arbitrary decision on which control characters should be returned as their own characters and which shouldn't. Better terminal environments don't have this issue, but this isn't one of those environments. >I assume most terminal emulators follow in xterm's footsteps, so would that reset-mode and set-mode work on most terminal emulators? It probably would, but this requires the terminal to copy xterm, which not all necessarily do. >I can feel your disdain to what I'm trying to do. I of course look up to you, so I thought of renaming the library to linux-terminal-control, and making the library more portable, but within the Linux environment. (i.e. support more terminal emulators and whatnot) There's really not too terribly much to do. It's a matter of what to support more than anything. I'm flattered someone looks up to me. >I looked through atc's code though, and I felt discouraged after looking at it. The complexity alone for xterm's idiosyncracies, and the fact that I would also have to try to make library work with Unix signals, multiple implementations and terminal emulators, meant that it would be way more complex than the already complex code found in ATC. The majority of this library is entirely portable. The DIMENSIONS function depends on a specific behaviour when out-of-bounds coordinates are requested. My (SETF FOREGROUND) and (SETF BACKGROUND) must send a malformed sequence, purely because xterm implemented the standard incorrectly and others followed it blindly and unintelligently. The ERASE sends an xterm extension for clearing the scrollback, followed by a standard control function so as to lessen the possibility of poor behaviour from some terminals. Lastly is READ-EVENT, which I'll address later. Again, you should search for a POSIX signal handler library to address this issue of yours. Then, both libraries are used properly and don't fall to tangential concerns. After all, if ACUTE-TERMINAL-CONTROL permitted handling of SIGWINCH, that would require a much more general machinery to be added. >I'm sure you'll be happy to know I won't entertain of even trying to make this library a thing. The fact is, I'm too dumb to code at your level. I wasn't trying to denigrate you or be rude. You should disregard advice if you don't care for it. >I'll just stay with ATC and try to hack a solution for resizing (e.g. use read-event-no-hang and look at dimensions). I explained a solution for a program of mine earlier; you may be able to design your program similarly or you should seek out the POSIX signal handler library mentioned. >I have a question though, alot of code (like in read-event) is trying to work with xterm, but I'm not sure if you're just handling xterm or handling it along with other terminals at the same time. >My guess is the latter, since your philosophy is portability, but I want to hear from you. There is no standard I'm aware of for communicating mouse events; while I've my own ideas on how it should be done, only xterm's conventions, of which there are four, are implemented across every terminal I've tested with. I only support X10 mouse reporting because the better, albeit still broken, SGR mouse reporting isn't supported in the Linux framebuffer console, if I'm recalling correctly. Even so, I only interact with mouse clicks and decided I wouldn't support mouse releases, mouse hovering, mouse dragging, or other such things. As for function keys, the ECMA-48 standard has a FUNCTION KEY control function, but I'm not aware of it being used anywhere; the idiots decided to create their own nonstandard control functions that don't scale to infinity and vary wildly between terminals and even versions of terminals. In any case, I intend to add support for FUNCTION KEY later and, if I dig deeper and find that this can be enabled by an option, I'll gut the other code and require FUNCTION KEY control functions to be sent. As for the arrow keys, xterm sends the CURSOR UP, CURSOR DOWN, CURSOR LEFT, or CURSOR RIGHT control functions and I find this a perfectly reasonable behaviour and so have no issue with adding support for this once I get around to it. >Thanks. It's no issue. I don't want to insult or discourage you.
Batou · 2019-05-25 06:59
>>13724 >That would be every case. So, it becomes an arbitrary decision on which control characters should be returned as their own characters and which shouldn't. Would having a varible determine which is sent be a bad idea? >It probably would, but this requires the terminal to copy xterm, which not all necessarily do. In your experience, which terminal emulators copy xterm. >There's really not too terribly much to do. It's a matter of what to support more than anything. I assume that by handling xterm, you already are handling the other terminal emulators that copy xterm. Then what's left is handling other prominent terminal emulators. >I'm flattered someone looks up to me. You're welcome. I lookup to you because you are what I hope to be i.e. an employed lisp programmer, and also because you are knoeledgeable and able to make very complex programs. >The majority of this library is entirely portable. ... So these functions you listed, would work only with xterm et al. Except erase, which you said also sends a standard control function. >I wasn't trying to denigrate you or be rude. Thanks for the clarification, I felt weird after I had read your last reply. >You should disregard advice if you don't care for it. Normally I would, if it came from some random /dpt/ anon, but it's different with you. Lainchan is a smaller community and I've known about you for more than six months now. It would be like ignoring $PROMINENT-PROGRAMMER's advice. >I explained a solution for a program of mine earlier; you may be able to design your program similarly or you should seek out the POSIX signal handler library mentioned. It seems overkill to use a signal handling library for just resizing, maybe if I could also do some other things. Actually, now thinking about it, would this library help with signals like C-c and C-z? >Even so, I only interact with mouse clicks and decided I wouldn't support mouse releases, mouse hovering, mouse dragging, or other such things. Are they too complex to handle? >I intend to add support for FUNCTION KEY later I'm confused, I thought events like (:function . 10) were already supported. >It's no issue. I don't want to insult or discourage you. Glad to know. But I still know I'm not capable of writing what I need. So I was thinking, you probably aren't open to writing a library like linux-terminal-control out of your own volition. Maybe you would write it if you gained monetary compensation. I've never contracted anyone before, so I don't even know how it's all supposed to work. My question would be what you would charge, but that obviously depends on what exact functionality I need, the complexity of the code you would need to write and how much time you would devote to it. There's a number of variables at work, but I would like to know: Are you're open to this?
(princ tripcode) -| · 2019-05-25 13:05
>>13726 >Would having a varible determine which is sent be a bad idea? I'd rather avoid global variables such as this, if I could help it. >In your experience, which terminal emulators copy xterm. In my experience, all of them do. >I assume that by handling xterm, you already are handling the other terminal emulators that copy xterm. Then what's left is handling other prominent terminal emulators. Well, xterm merely extends ECMA-48, so it's all a superset of ECMA-48. >You're welcome. I lookup to you because you are what I hope to be i.e. an employed lisp programmer, and also because you are knoeledgeable and able to make very complex programs. I don't want to misrepresent myself here. I've not been employed as an actual Lisp programmer; I was supposed to be at one point, but it degenerated into making a webapp instead. Now, I don't usually share details about my personal life here, but I'll simply let you know I'm currently interviewing with a US defense contractor; I wouldn't be using any Lisp there, either, but doing lower-level work. >So these functions you listed, would work only with xterm et al. Except erase, which you said also sends a standard control function. No. The DIMENSIONS depends on a particular behaviour which allows me to write it in Common Lisp and the other two should be portable, but xterm et al. implement it improperly and so I also begrudgingly do so. >Thanks for the clarification, I felt weird after I had read your last reply. That's unfortunate. I don't want to make anyone here feel unwelcome or weird, as you put it. >Normally I would, if it came from some random /dpt/ anon, but it's different with you. Lainchan is a smaller community and I've known about you for more than six months now. It would be like ignoring $PROMINENT-PROGRAMMER's advice. I'm flattered. >It seems overkill to use a signal handling library for just resizing, maybe if I could also do some other things. >Actually, now thinking about it, would this library help with signals like C-c and C-z? Those signals would be SIGTERM and SIGTSTP, respectively, and yes. >Are they too complex to handle? No, but they lead to a great deal of mostly useless events and I decided it would be useless and wasteful for almost every program. >I'm confused, I thought events like (:function . 10) were already supported. I intend to support the standard method of communicating function key presses, despite not seeing these ever used before. Currently, READ-EVENT supports a subset of the xterm-family control sequences for these, which are all I've ever actually seen used. >So I was thinking, you probably aren't open to writing a library like linux-terminal-control out of your own volition. Maybe you would write it if you gained monetary compensation. >I've never contracted anyone before, so I don't even know how it's all supposed to work. Oh my, what a neat idea. How it works is you tell me what you want, I tell you what I charge, I get paid since I can be relied on to not discard my reputation for a little money, and then I give you what you want. >My question would be what you would charge, but that obviously depends on what exact functionality I need, the complexity of the code you would need to write and how much time you would devote to it. There's a number of variables at work, but I would like to know: Are you're open to this? I'd be open to writing an ACUTE-TERMINAL-CONTROL-EXTENSIONS or ATC-EXTENSIONS package that contained the functionality you want at a high-level. You probably don't want all that much, and it would likely take me little time, so I suppose $100.00 would be a good price, although this can change if you wanted something very complex. I've been intending to create a Bitcoin wallet so that I could solicit it on my website or Gopher hole for those who'd be interested in giving me money for no particular reason. Would you be open to paying me in Bitcoin? Unless you already have some, I wouldn't recommend gaining any until after this has all been discussed.
Tequila · 2019-05-25 21:31
>>13730 >I'd be open to writing an ACUTE-TERMINAL-CONTROL-EXTENSIONS or ATC-EXTENSIONS package that contained the functionality you want at a high-level. You probably don't want all that much, and it would likely take me little time, so I suppose $100.00 would be a good price, although this can change if you wanted something very complex. I've been intending to create a Bitcoin wallet so that I could solicit it on my website or Gopher hole for those who'd be interested in giving me money for no particular reason. Would you be open to paying me in Bitcoin? Unless you already have some, I wouldn't recommend gaining any until after this has all been discussed. 100 dollars seem fine to me. As for bitcoin, I don't have any, I guess we'd have to do something like paypal. Here's roughly what I would want, if you want me to make a more "professional" document detailing more, I can do so. This is a rough draft, I can keep revising so as to make the price not steep and keep it 100 dollars (or close to it) >new added events to read-event/no-hang including :resize, (control: char), (alt: char), (meta: char), :up, :down, :left, :right events >in the case for ambiguity, add a global variable which determines which to recieve >two functions to enable/disable cursor being shown (I know you've shown me how to do it with the cl-ecma-48, but I'd want these functions to work with non-xterm terminal emulators too) >support for xterm, urxvt, st, and linux framebuffer (of course if you feel like some features are much difficult to add for certain terminals, and would mean an increased price, drop it or tell me) >also, urxvt is the main terminal I care for, so having urxvt work with as most features is most important to me As for the time frame, you can take your time, in fact, since I'm poor myself, and I don't even work (I just study), that'd be better so I can gather the money together and still have money for food. Tell me what you think the price should be for each feature, and then I'll get back to you with a revised version.
SHODAN · 2019-05-26 00:20
>>13738 omg why did I type the keywords with the : after I mean, (:control char) (:alt char), (:meta char) also, since you said you are going to add in :up, :down, :left, and :right, :meta and :alt events to atc anyways, I'd like to omit them if it increases the price.
Kay · 2019-05-26 01:05
Hmm, it now seems to me most of what I want is already provided. (of course, only if you go ahead and implement the (:alt char) and (:meta char) along with the arrow keys events into atc) I don't really need a (:control char) event, I can just process the char that pressing C-char would give and treat it as (:control char) The other events you already plan to implement (hopefully) into atc, except resizing. But you said you had a solution for resizing already (could you point me to the solution) I've yet to test the cursor on/off code you gave, and I do need that. I'll come back to you later, I'll test that cursor on/off code on terminals I care for, and also that resizing solution you talked about. I'm sorry I got your hopes up, I'd gladly pay (albeit a smaller amount because the functionality needed is reduced) if I do need the resizing event and the cursor on/off functions.
Boris Grishenko · 2019-05-26 02:56
I've tested the (ecma-48:reset-mode '(#\? 25)) (ecma-48:set-mode '(#\? 25)) and they seem to work with all the terminals I care for. So now what't left is the resizing event.
Knuth · 2019-05-26 03:06
I've got to say though, ecma-48 and atc are god send. Thank god for prince trippy/lisp, if it wasn't for him, I'd probably be using the soykaf that is ncurses.
(princ tripcode) -| · 2019-05-26 20:18
>>13738 >100 dollars seem fine to me. >As for bitcoin, I don't have any, I guess we'd have to do something like paypal. I'd prefer to avoid Paypal. A resize isn't an event in the same sense of events that READ-EVENT or READ-EVENT-NO-HANG handle. >support for xterm, urxvt, st, and linux framebuffer >also, urxvt is the main terminal I care for, so having urxvt work with as most features is most important to me I feel either you misunderstood slightly or I didn't explain properly but, as you've noticed, most everything I've done works with most any terminal emulator. >>13745 >Hmm, it now seems to me most of what I want is already provided. (of course, only if you go ahead and implement the (:alt char) and (:meta char) along with the arrow keys events into atc) The Alt and Meta key is the same key. I may have this added by the end of the month, but may not. >I don't really need a (:control char) event, I can just process the char that pressing C-char would give and treat it as (:control char) That's what I'd recommend doing. >The other events you already plan to implement (hopefully) into atc, except resizing. >But you said you had a solution for resizing already (could you point me to the solution) I explained how my MMC handles it here: >>13475 >I'm sorry I got your hopes up It's no issue and you didn't. I didn't write any of this expecting payment, anyway. >>13747 >I've got to say though, ecma-48 and atc are god send. >Thank god for prince trippy/lisp, if it wasn't for him, I'd probably be using the soykaf that is ncurses. I'm flattered, again.
Hououin Kyouma · 2019-05-27 08:00
>>13758 >A resize isn't an event in the same sense of events that READ-EVENT or READ-EVENT-NO-HANG handle. So how else would I know if a resize had happened if it isn't an event. >The Alt and Meta key is the same key. Then I'm confused, I know there's a difference between alt and what most people call the "windows key" They usually call them mod4 for alt, and mod-idk for the windows key. I'll look through your resizing solution though, to see what you're talking about.
(princ tripcode) -| · 2019-05-27 08:23
>>13765 >So how else would I know if a resize had happened if it isn't an event. An event in the sense of READ-EVENT and READ-EVENT-NO-HANG is input that is composed of composite data that signifies a higher event, such as a function key press. An event in terms of a resize, which is a SIGWINCH, which is a POSIX signal, is an event that mindlessly redirects program control to a registered routine called a handler. As you can guess, a Lisp system could have issues with control flow being yanked out from under it at any point, which is why many handlers simply set a flag and then return to what was being done beforehand. The default handler for many signals, including SIGWINCH, is simply to entirely ignore it. >Then I'm confused, I know there's a difference between alt and what most people call the "windows key" That is the Super key and I'm not certain any terminals do anything with it at all. >I'll look through your resizing solution though, to see what you're talking about. That's good. If I had SIGWINCH support, all I'd use it for is to set a flag that I'd check in the main loop for resizing, but it's easy enough to work without it and some programs don't need to respond to it at all. It depends on what you're doing.
renames · 2019-05-27 08:44
>>13766 >which is why many handlers simply set a flag and then return to what was being done beforehand. The default handler for many signals, including SIGWINCH, is simply to entirely ignore it. And by default handling I assume non lisp handlers. Theoreticaly, if I seeked that a cl posix signal library, I could just assign a lambda function handler that sets a resize variable to t I could do the same for C-z and C-c "events" if I wanted then. I'll look more into it, seems simple in theory. >That is the Super key and I'm not certain any terminals do anything with it at all. Are you opposed to adding it in? I don't see why not since you "intend to support the standard method of communicating function key presses, despite not seeing these ever used before."
(princ tripcode) -| · 2019-05-27 17:08
>>13767 >And by default handling I assume non lisp handlers. Yes. I believe I've read the Python interpreter permits handlers in Python by using its own handlers to alert it to call the Python handlers. >Theoreticaly, if I seeked that a cl posix signal library, I could just assign a lambda function handler that sets a resize variable to t >I could do the same for C-z and C-c "events" if I wanted then. Yes. >I'll look more into it, seems simple in theory. These signals are actually a very poor mechanism compared to how Multics and other systems do it, but it's what we're stuck with. Multics in particular had a system resembling the Common Lisp condition system, because PL/I had such a system that inspired the condition system. This allows easy handler binding and unbinding, along with delegating to earlier handlers and whatnot, whereas UNIX has a poor, single global handler mechanism. >Are you opposed to adding it in? You misunderstand. I'm not certain any terminals do anything with it in a way that can be recognized by a program. I'm not certain it's an option at all.
(princ tripcode) -| · 2019-05-29 05:01
The latest version of ACUTE-TERMINAL-CONTROL is in the usual locations: http://verisimilitudes.net/acute-terminal-control.lisp gopher://verisimilitudes.net/0acute-terminal-control.lisp The changes are all in READ-EVENT and so also READ-EVENT-NO-HANG. These will now test the eighth bit to determine whether the event is a (:META . #\character) event or not; there's another convention for doing so that prefixes characters with the escape character, but I'm not certain I'll implement that convention. These two functions will also return :UP, :DOWN, :LEFT, or :RIGHT for cursor key events. I've not yet changed the documentation to reflect these changes, note.
Mitnick · 2019-05-31 21:33
>>13786 >>13786 Nice. Too bad it the meta event only works on xterm. :up, :down, :left, and :right do work on other terminals though, so that's nice.
(princ tripcode) -| · 2019-06-01 22:31
I skulked around, but most terminals don't even offer the option to change the Meta key convention. I have changed ATC to only accept the different convention, prefixing escape. On the bright side, this means you can input Meta key events with character sets other than ASCII. I've gone ahead and tested these changes and the READ-EVENT function somewhat extensively in general and am rather confident it works correctly. I suppose these two functions are one of the main components of ATC, now. I'm considering adding the silly delete key convention, but it would be better to simply set your terminal to send the proper character when you press it, rather than this backspace, delete, escape followed by [3~ nonsense. Sans that, I'm not certain what else I'd add, not that anything necessarily needs to be added at this point. The file is in the same locations, of course.
Anonymous · 2019-06-02 01:52
>>13806 Nice, the new version allows for meta events in non xterm to happen. Ironically, xterm doesn't properly process it now, and instead arbitrary characters like latin characters are sent lol. This can be fixed by adding this xterm*eighBitInput: false to .Xresources though
H.R. Giger · 2019-06-02 02:05
lisp: I'm happy with the current state of ATC, it seems to provide most of what I want. I haven't yet tested the resizing solution, but I have a good feeling it will work nicely. I'll soon start working on that windows library. Hopefully, when I'm done with it, it'll have functionality superior to ncurses windows/panels (in my opinion anyways) I'll try to make it portable of course, but that'll probably require that #+ reader macro, which I'm not much familar with.
Neo · 2019-06-02 02:11
>>13809 Of course, I hope you don't abandon ATC, and instead keep refining it to make it even better.
(princ tripcode) -| · 2019-06-02 21:47
>>13808 This is the configuration I was shown to enable that, in ~/.Xdefaults: XTerm*vt100*eightBitInput: true To get the typical behavior, this was in my default ~/.Xdefaults: XTerm*metaSendsEscape: true >>13809 >lisp: I'm happy with the current state of ATC, it seems to provide most of what I want. I'm glad and, again, I'm (princ tripcode) -| here. >I'll soon start working on that windows library. >Hopefully, when I'm done with it, it'll have functionality superior to ncurses windows/panels (in my opinion anyways) >I'll try to make it portable of course, but that'll probably require that #+ reader macro, which I'm not much familar with. I don't see why building pseudo-windowing functionality with ATC would require unportable code, but I anticipate seeing what you have, when you have it. >>13810 Finished code isn't abandoned, although I don't believe ATC is quite finished yet.
Elliot Alderson · 2019-06-10 18:01
Is there any real alternative of quicklisp beside managing all the dependencies manually? I'm trying to start my first ever lisp project but I find it extremely uncomfortable that quicklisp downloads package tarballs over http.
Vasya Pupkin · 2019-06-10 18:47
>>13891 Yeah, use Clojure.
progn · 2019-06-10 19:00
>>13891 >Is there any real alternative of quicklisp beside managing all the dependencies manually? I'm familiar with Ultralisp; I use neither, though: https://ultralisp.org/ >I'm trying to start my first ever lisp project but I find it extremely uncomfortable that quicklisp downloads package tarballs over http. I feel similarly. I've been wanting to have my own system for this that's superior, but just one issue is how HTTP has become the predominant file transfer mechanism of the Internet and so rather demands such software contain its own client, among other issues, such as being busy with other work. If you'd care to learn more about my planned system, just ask, in any case.
Hacker · 2019-06-10 19:48
>>13892 Cloure is not common lisp implementation >>13894 Isn't ultralisp built on top of quicklisp? Does it ship with its own fetch method that supports https or even ssh? I wouldn't really mind getting files over http as long as packages are signed & key is distributed on the initial install like openbsd's packages or debian apt do but the way quicklisp handles the situation should not be considered acceptable in 21C IMHO. What kind of alternative do you suggest tho? I was thinking about transitioning to guix after all
Debbie Charteris · 2019-06-11 00:05
>>13896 >Isn't ultralisp built on top of quicklisp? Does it ship with its own fetch method that supports https or even ssh? That I wouldn't know. >I wouldn't really mind getting files over http as long as packages are signed & key is distributed on the initial install like openbsd's packages or debian apt do but the way quicklisp handles the situation should not be considered acceptable in 21C IMHO. I agree that it's unacceptable to the degree that Quicklisp should be replaced. >What kind of alternative do you suggest tho? I was thinking about transitioning to guix after all My idea was decentralization. So, you have one person distribute a list of package names, versions, dependencies, hash checksums, places to find them, etc. and then installing a package simply uses a downloader to retrieve and validate what's necessary. Decentralization would be a better way to do Lisp packaging, rather than Quicklisp's centralized approach. The main issue with this is writing all of the necessary programs in Common Lisp is a large task and it would be easier to simply use tools that are already on the machine, but that's seems unsatisfying.
Tomohisa "Tom" Kanezaki · 2019-06-22 11:47
Man i want a lisp keyboard like that
Cowboy · 2019-06-27 18:04
How can you have the behaviour of progn (multiple evaluation) but without returning anything? >>14008 They invented the like and dislike buttons. Way ahead of their time.
Switch · 2019-06-27 18:36
>>14008 >>14040 Given the status of parenthesis in Lisp I'm suprised they're still accessed via shift instead of having a dedicated key
Miho Iwakura · 2019-06-27 23:35
>>14040 You could end it with a call to VALUES lacking any parameters. You could use a TAGBODY in some cases. You could use (PROG1 NIL ...) also. >>14041 Observe the parentheses keys near the return key.
vector · 2019-06-28 00:32
>>14043 So, there's no ANSI solution for that? I could write a macro with a lambda on it. I use that kind of behaviour a lot.
Hong, Guil Dong · 2019-06-28 03:49
>>14040 >>14045 That sounds like a really strange thing to do. What's your use case?
limited · 2019-06-28 04:56
>>14049 Maybe my approach is incorrect: (do ((nchar (read-char stream nil) (read-char stream nil)) (open-close 0) (start-end 0) (opened 0) (closed 0)) ;STOP CONDITION || RETURN VALUE ((null nchar) (+ open-close start-end (- opened closed) ) ) (if (= 0 open-close) ;;true (cond ((and (char= #\< nchar)(char= #\/ (peek-char nil stream))) ;;CONDITION (progn (incf opened 1) (incf open-close 1) (decf start-end 1))) ((char= #\< nchar) ;;CONDITION (progn (incf opened 1) (incf open-close 1) (incf start-end 1))) ((char= #\> nchar) ;;CONDITION (incf closed 1) )) ;;false (cond ((char= #\< nchar) ;;CONDITION (progn (incf open-close 1) (incf opened 1))) ((and (char= #\/ nchar) (char= #\> (peek-char nil stream)) ;;CONDITION (decf start-end 1))) ((char= #\> nchar) ;;CONDITION (progn (incf closed 1)(decf open-close 1)))) )) I'm trying to use progn to have multiple expressions evaluated but to me that doesn't seem so elegant.
hash table · 2019-06-29 21:21
>>14045 >So, there's no ANSI solution for that? I just gave you several. If you truly want no values, rather than NIL in that case, use the PROGN, which will correctly communicate this. >>14052 You don't need this behavior in that at all. It's not even present. A COND has an implicit PROGN. The return value of that IF is irrelevant in this.
Meddler · 2019-07-01 09:57
What Scheme is a good bash replacement for everyday scripting? The original scsh is unmaintained. The fork at https://github.com/scheme/scsh is semi-maintained, but has things changed around in ways that contradict the documentation. I think I've also encountered bugs that weren't there in the original. The other options are * Racket + http://rash-lang.org/, but Racket starts up slowly and Rash is alpha-quality. * Guile, because it's everywhere. * CHICKEN and scsh-process (http://eggs.call-cc.org/5/) * Gauche and http://practical-scheme.net/gauche/man/gauche-refe/System-interface.html#System-interface Which have you personally used?
bit · 2019-07-02 22:28
>>14090 Guile is everywhere and has good tooling for making scripting easy. https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html#Scripting-Examples
Davis · 2019-07-05 05:43
So, as long as I don't use compiler specific directives, is it relatively simple to covert from CL to Elisp?
Turner · 2019-07-05 08:01
>>14132 cl.el should be enough for trivial programs, but it's a shim to appease CL programmers, not a complete implementation. Big programs will run into a lot of small issues. Also while It's generally easy to translate from one lisp to another, good style in one dialect is often considered ugly in another, and that goes double for idiosyncratic lisps like Elisp. For example, Elisp has EIEIO which implements something like CLOS, but I've literally never seen it used.
Nguoi La · 2019-07-05 15:40
>>14133 Didn't know there was a tool. Thanks for that.
Jet Black · 2019-07-17 17:40
Educational Pearl Automata via Macros LTU post: http://lambda-the-ultimate.org/node/569 This is why we love Lisp.
Nemissa · 2019-07-20 07:19
>>14266 Nice. Thanks for sharing anon.
Void · 2019-07-29 18:21
Hey fellow lainons, I'm thinking of writing a web application in Chicken Scheme, could anyone recommend me a good framework/library for doing so?
Jet Black · 2019-07-29 19:26
>>14404 if you've never done it before, I recommend going with CGI and doing it yourself. Read the RFCs. Print out headers and then strings containing HTML. Read post bodies from stdin, and check environment variables for communication from the webserver. 1. it's easier than you think. 96.666% of the benefit of a framework is just documentation: the framework's docs tell you how to do things. But what the framework actually, programmatically does for you is more like a "math framework" that gives you (add-two-numbers (add-two-numbers 1 2) 3) interfaces. It's less powerful than what it's standing on; it's not that well designed; it's not even any easier to use than what it's standing on. 2. it scales just fine for your needs. And if you get a good grasp on what's actually on, rather than mastering some specific framework, then you'll have an easier time scaling things yourself. 3. you can start cheap, with cPanel shared hosting from anywhere. 4. Chicken Scheme is perfectly suitable for small programs that are quick to start up, do their thing, and exit. 5. it's closer to how things actually happen in the industry than you think. Download WordPress some time. What's its 'framework'? The answer is: it's just PHP and it mostly prints out strings with HTML in them, and meanwhile PHP does very little to support this. PHP has some header management and some buffering, and some special variables to handle query arguments and form input. The end.
Incognito · 2019-07-31 07:18
>>14404 The best way to write WWW programs in Lisp is to have the server written in Lisp and all dynamic material then becomes a simple procedure call; neither of CGI nor FastCGI will be faster than that. I've read people tend to put the Lisp servers behind NGINX though, so I suppose it wouldn't entirely free you from learning how to configure them.
limited · 2019-07-31 07:30
>>14434 >neither of CGI nor FastCGI will be faster than that. suppose you want your website to run from a datacenter instead of from your house. You then have to pay for it. you could A. spend $5/month for shared hosting, where CGI is possible but your own webserver is not (long-running procs get auto-killed). This might be a with 32 CPUs and 1x-2x+ as many GBs of RAM. B. spend $5/month for a seriously low-end VPS so that you can run your webserver. This is likely to be even more oversold than really bad shared, because the owner is hoping to inflate his apparent customer base and then get bought out. C. pay much more for a decent VPS that's still relatively resource-starved vs. the shared option D. pay much more for a dedicated server. This is honestly a good option but now instead of "I want a website" you have "I want a website and also I want to admin a daemon and also I want to admin the server it runs on". You're forking over more money for more work. Still, it's very competitive with option A. B and C, I'd only recommend if you actually can't do CGI. Like if you want to use SBCL instead of Chicken Scheme.
Switch · 2019-07-31 20:58
>>14435 Those are all good points I'd not considered, since I have an entire virtual server I rent. I agree that using CGI or FastCGI does provide the option of all of those renters that only offer this as an interface and that seems to be a surprisingly attractive option to many people. One nice quality of renting an entire virtual server is the ability to use it for more than just the WWW; I use mine for various protocols, including hosting my own email, and other things; it can be a bother to administrate an entire server, but the big daemons are usually heavily automated by whatever package manager your operating system provides, anyway. You could also look at it as a learning experience, perhaps. I've not really seen much of a difference between your options B, C, and D; I just rent a cheap server and even less than $5.00 per month gives me a machine several times more powerful and with more bandwidth than I need; I'd draw a bigger line between renting at all and hosting the server in your own house or otherwise under your direct control; this can reveal your general location and requires a good and constant Internet connection that doesn't block the ports you use, though. Still, all of this is worth considering when using Lisp for dynamic WWW pages; of note, I've seen not too long back that several renters provide specialized Lisp options for Common Lisp and Scheme, I believe most commonly under SBCL and Guile, so it's not as niche as it may seem.
Roger Pollack · 2019-08-04 15:16
Random · 2019-08-05 01:26
>>14498 did you mean to reply to >>10489 in the other thread? Or this a little bit of proselytization?
Joey · 2019-08-05 03:25
>>14508 I just wanted to share it since it wasn’t available as pdf for a long time.
if · 2019-08-09 22:09
>>14435 Another option might be to use zeit/now's free tier using version 1 (NOT version 2) of their service. If you can make a Dockerfile for your lisp application, you should be able to deploy to them. https://zeit.co/docs/v1/deployment-types/docker/
Acid Burn · 2019-08-18 11:38
>>13481 >StumpWM >>13496 My mental processes hate tiling WMs for several reasons, some known and some unknown. What I know is that I need to let windows be in their original positions, not jumping around; I send them to the back/front but they must not change size. I cringe if text is reformatted because the window sizes change. If I still want to try a lispy WM, but stacking, would sawfish be at a similar level of sophisticacion than StumpWM is?
Lain Iwakura · 2019-08-20 23:10
Hi lainons, I'm currently learning OOP in GNU Guile (a Scheme dialect). GOOPS is made in a similar manner to the Common Lisp Object System and here comes my question: do I need to know much about generic functions to be able to make good OO programs? Could you please tell me using simple language, what are generic functions and why do I need them? English is not my native language and reading about highly abstract concepts can be difficult, so I want to make sure if it's worth it - I could just skip reading this chapter and come back to it later.
Jim Hilger · 2019-08-21 07:41
>>14804 A generic function isn't some kind of magic. It is in fact a collection of functions that apply get dispatched to specific objects. So it includes all the object specific methods that have the same name as the generic function. In fact lets say that we have 2 classes and we want to implement an addition specific to each of them: (defgeneric add (x y)) (defmethod add ((x class1) (y class2)) ...) (defmethod add ((x class2) (y class2)) ...) For a great intro to CLOS and the ideas behind it check https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol
sizeof · 2019-08-21 22:35
>>14811 >A generic function isn't some kind of magic I mean of course it's not magic, but is it something I ought to know, in order to make applications using GOOPS, or is it an advanced feature used only by low level interface under the hood, in order to manage features of the language itself?
Void · 2019-08-22 03:37
>>14804 You need to know about generic functions. They're very similar to overloaded methods from Java, C#, or C++.
Mentat · 2019-08-22 13:43
>>14816 I just meant that generic functions don't have that much to learn for. I haven't really played with GOOPS, but in CLOS they are pretty "natural". For example multiple dispatch is easy, you just define a method with arguments from various classes. If you've ever done multiple dispatch in Java or Ruby you can understand how easy that is.
Eldon Tyrell · 2019-08-22 16:40
>>14825 >I just meant that generic functions don't have that much to learn for. I haven't really played with GOOPS, but in CLOS they are pretty "natural". From GOOPS manual: "Note that define-method automatically does a define-generic if the identifier concerned is not already a generic function, so often an explicit define-generic call is not needed." I just didn't see the point of using this at all if it is automatically done, don't know about its further use though, so I'm going to read the chapter anyway. In GOOPS it's just: (define-generic add) But by defining a method, it's done automatically anyway. Is CLOS any different?
protected · 2019-08-22 17:00
>>14829 In general if your methods are simple you don't use defgeneric in CLOS as well. The thing is that defgeneric can be used for setting things that are used in all the included methods. Things like that are documentation, the functions or methods classes, method combinations etc.
Pris · 2019-08-23 18:18
Is it just me, or does this problem seem unreasonably difficult for early on in a Lisp book? The book has only just covered recursion slightly, hasn't even gotten to iteration yet. Introduced the idea of a binary tree in a short paragraph and then was like alright here's some problems to solve! I've been trying to just dive in, but I honestly have no clue how to deal with the requirements. I tried to at least get the simplest case correct, a single equation, but to expand from there not only do I need to dive through the tree, but also keep track of the registers, since the result of each calculation is stored in the first register. So like, keep track that register 1 is occupied, thus start further calculations with register 2, or 3 etc. Here's my (obviously incorrect) attempt: (defun ccompi (eqt) (cond ((null eqt) nil) ((atom eqt) eqt) ((and (atom (cadr eqt)) (atom (caddr eqt))) (list (list 'move 1 (cadr eqt)) (list 'move 2 (caddr eqt)) (list (cond ((equal (car eqt) '/) 'div) ((equal (car eqt) '*) 'mul) ((equal (car eqt) '-) 'sub) ((equal (car eqt) '+) 'add)) (cadr eqt) (caddr eqt)))) (t (list (ccompi (cadr eqt)) (ccompi (caddr eqt)))))) Any insights would be appreciated.
Zhora · 2019-08-24 07:46
>>14858 I might have come up with something. Will post after test. Also yeah, technical books are often written by retards who can’t teach a subject correctly. For example, a famous book about algorithms asks you to write an algorithm to solve the matrix chain multiplication problem. IN THE INTRO CHAPTER Needless to say that is impossible for anyone new to algorithm to solve that. And of course, they provide you with no solutions. Books are often like that.
Hitomi · 2019-08-29 22:22
I made an EPUB reader with Clojure. https://github.com/netb258/clj-pub
Richard Axacov · 2019-09-01 11:10
Are there any good exercise for understanding call/cc thing?
Nanashi No Gombe · 2019-09-01 11:35
>>14964 What did you use for the gui? javafx? How was the experience? I want to develop some gtk/qt based gui applications but I haven't really found a good workflow with anyone of the major lisp languages. Rackets gui comes close though.
Naomi Nascimento · 2019-09-04 04:33
I know this poster is probably long gone, but it seemed like a cool problem. My attempt is: (define (compile expression) (let ((op-to-name (lambda (op) (cond [(equal? op '+) 'ADD] [(equal? op '-) 'SUB] [(equal? op '/) 'DIV] [(equal? op '*) 'MUL])))) (let compileh ([offset 1] [expr expression]) (if (symbol? expr) `((MOVE ,offset ,expr)) (append (compileh offset (cadr expr)) (compileh (+ offset 1) (caddr expr)) `((,(op-to-name (car expr)) ,offset ,(+ offset 1)))))))) The logic of the algorithm is the compileh function, which basically uses an offset to control the scope of a function, which is then immediately condensed into one register.
Dox · 2019-09-04 07:54
>>15029 Some notes: 1. To declare a local function, such as "op-to-name" you don't need a let expression, you can just add another define before the let-loop. 2. There's no need to check the equality of symbols using "equal?", since a. "eq?" must suffice for symbol-equality and b. must scheme's have a "case" form. And this is just nitpicking, but I think that "compileh" isn't the nicest name, maybe something like "helper" or "loop" would have been better. But that's unrelated to the code.
Agent Richard Gill · 2019-09-04 07:56
>>15030 Another thing, the whole "op-to-name" (that should be written "op->name" in idiomatic scheme) could also just be an alist. Other than that a good algorithm!
Ivan Horvat · 2019-09-04 18:06
>>15030 >>15031 Thanks for the feedback, as I'm (apparently clearly) new to scheme. Here's a V2: (define (compile expression) (define opcodes (list (cons '+ 'ADD) (cons '- 'SUB) (cons '/ 'DIV) (cons '* 'MUL))) (let compile-helper ([offset 1] [expr expression]) (if (symbol? expr) `((MOVE ,offset ,expr)) (append (compile-helper offset (cadr expr)) (compile-helper (+ offset 1) (caddr expr)) `((,(cdr (assq (car expr) opcodes)) ,offset ,(+ offset 1))))))) If there's anything else (either algorithmically or syntactically) I should fix, I'm all ears. I really appreciate the feedback.
Yuki Nagato · 2019-09-04 18:07
>>15034 I don't know if this is the best way to make alists in chez scheme, but it works okay.
Dozer · 2019-09-04 20:23
>>15034 Well I could give you my version, which is also totally subjective when it comes to taste: (define (compile expression) (define op-table '((+ . ADD) (- . SUB) (/ . DIV) (* . MUL))) (define (llist . args) (list (apply list args))) (let loop ((offset 1) (expr expression)) (if (symbol? expr) (llist 'MOVE offset expr) (append (loop offset (cadr expr)) (loop (1+ offset) (caddr expr)) (llist (assq-ref op-table (car expr)) offset (1+ offset)))))) What I see in your code that I find "peculiar" is that one the one hand you construct your alist using list and cons, as >>15035 pointed out, but then use backquotes later on. Also, it's usual to use the "1+" function rather than doing "(+ x 1)", even though it only saves a space, it conveys the semantic information that you're explicitly incrementing the number by one, rather than by some number. Finally, I'm not sure if your scheme impl. supports this, but "assq-ref" should do the same as "(cdr (assq ...))". One thing I was thinking about when it came to the algorithm was if it would be possible to avoid "append", since this means constant memory allocation (each time you copy all your cons cells). As far as I see, "append!", the destructive alternative, should also work, but I don't see any way one could construct the list from back to front and then reverse it that would be more intelligent. Maybe that would be worth investigating? Also fun, if you have it, using the "match" macro to avoid doing "(cad*r expr)" all the time.
Jim Hilger · 2019-09-04 23:55
>>15037 You could do it imperatively, which only uses recursion for walking the tree, but uses a list to actually store the instructions: (define (compile expression) (define operations '()) (define opcodes `(,(cons '+ 'ADD) ,(cons '- 'SUB) ,(cons '/ 'DIV) ,(cons '* 'MUL))) (let compile-helper ([offset 1] [expr expression]) (set! operations (append operations (if (symbol? expr) `((MOVE ,offset ,expr)) (begin (compile-helper offset (cadr expr)) (compile-helper (1+ offset) (caddr expr)) `(( ,(cdr (assq (car expr) opcodes)) ,offset ,(1+ offset)))))))) operations)
St. IGNUcius · 2019-09-05 08:10
>>15040 I'm not sure this works the way it should. When trying it with the example from the image above, all I get is ((MUL 1 2)) . Other than that, I don't really get the benefit of doing this. Using "set!" seems to be to obfuscate the code, since you're trying much more on side effects to manipulate an outside data structure, than you would when you would build it on the stack.
swap · 2019-09-05 15:40
>>15046 Funnily enough, this works for me on chez scheme 9.5, but not guile 2.2.6. I think returning a list that's been set! may be implementation-defined behavior. Ideally, this would remove the need to allocate and re-allocate arrays by just appending each step onto the end of the operations list.
Unknown · 2019-09-05 15:45
>>15048 >>15048 >Ideally, this would remove the need to allocate and re-allocate arrays by just appending each step onto the end of the operations list. You're still re-allocating, since append is non-destructive. If you want to prevent re-allocation, try to use "append!" (as mentioned above). Ideally you would want a tail-recursive function, where you would pass on the operations as a argument from one call to another. Also, "opcodes" is still weird, because of all the quoting and unquoting. Any (cons 'a 'b) is the same thing as '(a . b) .
Von Neumann · 2019-09-05 16:33
>>15049 The note about opcodes makes sense - I didn't know scheme had that reader macro. The code above runs on chez, but not on guile. I think how I'm using set! and define may be considered undefined behavior. I wasn't able to use append! to work with either. I don' think TCO is at all possible here, because of the tree-like nature of the recursion.
Lady Jessica · 2019-09-05 19:32
>>15051 The first time I read your post, I thought you misunderstood the difference between "append" and "append!", so I made this quick sketch, but as far as I see, I misread something. I'm going to post it anyways, in case it helps someone else. fyi, it's the same difference as between append and nconc in classical lisps. >I think how I'm using set! and define may be considered undefined behavior. Well it would be better to define "operations" with a let block in this case, rather than with a define, but I don't think that was the mistake.
Lunch · 2019-09-06 00:12
What makes the Maybe monad in Haskell better than a Maybe macro is lisp? It seems that the macro would be faster and simpler to understand.
(princ tripcode) -| · 2019-09-06 04:00
It's been a tad since I've posted here with my name. This year so far has, for me, been filled with more writing, learning, experimentation, documenting, and other such things than it feels last year held, yet there is distinctly less Lisp programming and for related reasons I feel I've at least somewhat squandered the year so far. Reflecting on what I've accomplished in this year as of now, it feels I may work much harder with what's left. I no longer believe I'm going to finish an Ada reimplementation of my machine code development tool by the end of this year. The idea is still much too fuzzy for Ada, not to mention I don't have an Acute_Terminal_Control for Ada yet, and I believe I'll find myself rewriting the Common Lisp one last time, instead. Perhaps once I have a rather clear Common Lisp version, I'll be able to organize things well enough for an Ada reimplementation. A quick review shows that most of my Lisp programming for this year has been minor, albeit necessary, improvents to ACUTE-TERMINAL-CONTROL. I still have that JSON-SUCKER library in mind, but JSON is not pleasant and it's consequently unpleasant to work on. I'd have already written servers and tooling for some protocols, but I don't want to use USOCKET and have yet to work on my own networking library, although I've recently made some progress with respects to this; I'm working on Common Lisp and Ada networking libraries in parallel, letting the concerns of both languages influence the whole; Common Lisp is less flexible in this respect, however, since I'm restricted to the interfaces different implementations expose. An idea I've been entertaining for a long while is a new implementation of Common Lisp, with a focus solely on size rather than speed; I'd call it LittleCL. I wanted to start by implementing FORMATTER, LOOP, CASE, and some other macros, but I've yet to work on these past the implementation approach stage; both FORMATTER and LOOP should produce clear, readable, standard Common Lisp to the fullest extent reasonable and CASE should examine its cases to eliminate dead code and optimize to O(1) access where it's possible; these are qualities common implementations sorely lack. I expect to start some work on these sooner rather than later. I'm comfortable enough with Ada, now, that I've considered implementing a Lisp in Ada. I figured I could start with a LISP 1.5 interpreter and see how that goes. What do you think of that? I'd write the base of LittleCL in Ada, as that seems a good fit, is clearly-defined, and would give me a good base for size optimizations; that's a ways off, though, as I'd want the rest of the implementation finished first. I'd probably release more Common Lisp programs if I were satisfied with leaving them in a seemingly incomplete state and documenting them little, if at all, but not doing that is a matter of pride and differentiating myself from others, I suppose. I may release a smaller little program or library soon, however, concerning automated nonogram solving and what little work I've done in rule-based approaches to that, based entirely on my mulling over such puzzles myself. There is ever so much more I could write of, but this seems good and not much else comes to me currently. That's how I've been. How have you been?
queue · 2019-09-06 06:43
>>15056 Idk, probably that Haskell's Maybe can be used anywhere where the typesystem requires a Monad, while this doesn't have to be the case with Lisp? On the other hand, every value is a kind of Maybe, since it can be nil or non-nil, at least with CL & co.
hash table · 2019-09-06 14:12
Here's the problem I kept running into with append! , just to clear things up. The following code works imperatively, but has a 'what symbol at the beginning of the list: (define (compile expression) (define operations '(what)) (define opcodes `(,(cons '+ 'ADD) ,(cons '- 'SUB) ,(cons '/ 'DIV) ,(cons '* 'MUL))) (let compile-helper ([offset 1] [expr expression]) (append! operations (if (symbol? expr) `((MOVE ,offset ,expr)) (begin (compile-helper offset (cadr expr)) (compile-helper (1+ offset) (caddr expr)) `(( ,(cdr (assq (car expr) opcodes)) ,offset ,(1+ offset))))))) operations) If I change the last line from operations) to (cdr operations)) to remove the first element, it returns nothing. I can add cdr to the output and it works fine, but I can't for the life of me be able to put it in the function itself.
Richard Axacov · 2019-09-08 13:57
Hello, Lainons. What do you think about CL21? Is it easier than writing in pure Common Lisp?
Nobody · 2019-09-10 19:18
Why the hell LISP thread is not the most active one here? It is Lainchan, isn't it?
Jens Hansen · 2019-09-11 20:05
>>15141 There's been fourteen over the years so far, not including this one, by my rough count. I'd post more in this thread, but I've either been working towards non-Lisp pursuits or my Lisp pursuits aren't presentable yet. I'm thinking of working on a comprehensive Common Lisp library for TAR files. That could be neat and would ease me into working on some more complex file formats I'm looking at. What have you been working on in Lisp lately?
Bobby Newmark · 2019-09-11 20:51
>>15159 I have a very early version of a general ActivityPub library that I intend to use in some Common Lisp web apps.
Tyrell Wellick · 2019-09-12 07:31
>>15160 Oh, interesting. Are you implementing a JSON-ld parser, or are you manually reading the specification?
() · 2019-09-12 11:06
>>15169 I was working with cl-json-ld and also wanted to create an abstraction for databases using miro. Right now I'm mostly prototyping how to approach the issue and create a library that is useful but also abstract enough, so many web apps can reuse it. If I make enough progress and like define particular goals I will update here and release the code.
Molly Millions · 2019-09-12 17:53
I want to draw on pixel by pixel basis in Emacs. Is it possible? What should I look for?
Dujour · 2019-09-12 18:44
>>15185 Not natively, Emacs can display images as a face though (which is what docview and pdf-mode do, just try C-u C-x =). One could create a major-mode that creates a new image for every pixel update, and re-displays it, but it would be needlessly inefficient.
Lady 3Jane.. · 2019-09-12 21:23
>>15186 What's a face? I guess I am missong something here.
Marly Krushkhova · 2019-09-12 21:37
>>15187 https://www.gnu.org/software/emacs/manual/html_node/elisp/Faces.html
Eldon Tyrell · 2019-09-13 09:19
>>15188 >>15187 Oops, I mixed something up. Not faces, but text properties, basically what faces are implemented with, and especially the "display" property, is what it relevant to adding images or other non-textual items to buffers https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Property.html#Display-Property
(princ tripcode) -| · 2019-09-19 09:09
What a shame, I think, that my previous message has received no responses. I've made some progress on writing networking libraries so that I may finally begin to properly write some network client software in Common Lisp. I'll have my good thoughts on why this took me so long and whatnot available through my Finger server, later, but simply put I feel I was focusing too much on writing the ideal UDP interface from the start and ignoring the easier task of writing a TCP interface; well, I wrote this rough idea of what the client interface should be to give myself a reprieve and to have something on this nice date 2019-09-19. This message is due to my loosing an experimental interface I've lightly worked on; I call it EASY-PEASY-TCP: http://verisimilitudes.net/2019-09-19 For your convenience, I've attached the program as a file and here follows the documentation: Similarly to exiting the Common Lisp implementation, defining streams intimately and dynamically, or making use of multiple threads in program execution, among other features, Common Lisp requires code that isn't portable for instating network connections, if this is provided for at all. This library is a light experiment in pursuit of making this simple, starting with TCP/IPv4. This EASY-PEASY-TCP library was created to experiment with a simple TCP client interface and so also for writing simple network clients. I hold the opinion that the available Common Lisp libraries are complicated, mostly merely mirroring the baroque system interfaces presented with little abstraction and whatnot, and that this should be as trivial as it possibly can be. Simply put, I don't want the use of a TCP client connection to be any more involved than using the file system. This is also why there is a distinction made between client and server, as these are fundamentally different concepts and deserve fundamentally different interfaces. This library is licensed under the Creative Commons Zero Public Domain Dedication. This design is one function, a macro, and two conditions. This lone function is OPEN-TCP-CONNECTION and will ERROR with TCP-CONNECT-ERROR in the case of being unable to ESTABLISH a connection and with TCP-ERROR for all remaining failure cases; this function will return a STREAM and that may be closed with the standard CLOSE. The lone macro is WITH-TCP-CONNECTION and is analogous to WITH-OPEN-STREAM and WITH-OPEN-FILE. An IP address is represented as a SEQUENCE of the appropriate number of octets, with ports also being represented with simple integers with the appropriate bounds. This is an easy and trivial such interface and is more than suitable for basic network programs. It's noteworthy this interface isn't ideal, I think. From IETF RFC 793: the OPEN is present, albeit only capable of an active connection here, capable of a timeout, but this is lacking any of the more advanced options that TCP clients should have available; the SEND and RECEIVE are missing, but these can mostly be suitably replicated by the standard READing and PRINTing functions, although a refined control over or notice of the PUSH and URGENT flags would be pleasant; the CLOSE is rather accounted for; there is effectively no STATUS provided; and the ABORT is rather accounted for by that standard CLOSE mechanism. An ideal TCP client interface would, I think, permit creating an active connection to any IP address and TCP port with sensible default values for TCP extensions and other perhaps necessary but obscure options, such as timeouts, with that in particular defaulting to an indefinite and blocking waiting. The establishment, lifetime, and closing of TCP connections should have finely-grained CONDITIONs to enable better error handling. A prime issue with lacking explicit SEND and RECEIVE functionality is a current inability to provide CONDITIONs supplied by the library for certain failure cases and that aforementioned PUSH and URGENT flag control; a compromise would be providing such explicit functions for those cases where this is wanted and otherwise using normal functions, which makes this simpler, yet results in no loss of expressiveness. It would perhaps be nice to have an OPEN symbol that will exist solely to provide the illusion of a uniform interface for networking, over that standard OPEN. As mentioned, this library is experimental, and it currently only works under the SBCL and the CLISP implementations. There are likely bugs, as I've only glanced at the relevant documentation, and the implementation may be unnecessarily complex, inefficient, or otherwise unsuited for practical usage. I may improve this library dramatically later or I may leave this and create a new such library when I seek to improve upon the idea. I may choose to add more details to the ideal TCP client interface idea, later. Written in 2019 by Prince Trippy. This document is available under the CC0 Public Domain Dedication.
dictionary · 2019-09-19 21:53
Have anyone implemented a protocol using LISP? I would like to start my own DE project written in Guile Scheme using the Wayland protocol, but there doesn't exist any wayland client written in Guile yet, so I have to write one. Any hints on what I need to learn to be able to made this possible? AFAIK Wayland provides some XML files I have to generate binary code from, then sent it over UNIX domain socket to the server. Is there any toy program I can write to learn something more about networking on UNIX, protocols and communication between processes? Sorry if my explanation is too vague, I'm not really a developer, all I did was learning Guile myself for several months, web projects with client-server communication in JS and really simple programs in C++.
string · 2019-09-20 07:02
>>15282 In your case it would be easier to use Guile's foreign function interface, and do all the parsing/processing in C. But otherwise, there's no reason you would implement a protocol in any other way than an other language would.
Rick Deckard · 2019-09-22 13:20
So when reading comparisons Scheme and CL, often it comes up that CL is large and well stocked with usable things but with warts. They never specify what these warts actually are though? As a beginner, I don't know if I've just not dug deep enough yet to find any or I am too new to recognize these warts when I see them. My query is I guess, what would be an example of a CL "wart"?
Delilah · 2019-09-22 19:42
>>15336 Backwards compatibly with older lisps, meaning it's often less clean than Scheme. Superficial example would be that Scheme's desctructive function to set the cdr of a function is set-cdr! while CL has rplacd , like older lisps. Nothing horrible, just shows that CL chose to go with the same names that Lisp Machine Lisp and Maclisp used, instead of cleaner ones (then again, most people would do (setf (cdr x) y) instead of replacd ). Other thing that is related to this is the entire outwards facing system interface. For the sake of backwards compatibility (and formally forwards compatibility) no assumptions are made regarding what file system is used, so everything from non hierarchical, case insensitive files, or on the other hand versioning and explicit file types has to be handled. Most CL's can't start programs or send signals without special libraries. You can still do everything, but you see that a contemporary Linux system, for example, isn't the best friend of a Lisp environment.
setq · 2019-09-26 04:52
I've been starting reading about Rackets Macro system and its taken some time to get used to but its slowly making sense. I'd love to start using it to make some art-langs. I've read through Beautiful Racket, but it feels off relying on "non-standard" Racket, as it uses its own language for a large chunk of the backwork. Is there any recommended reading for this? other than the Racket guide which Ive been reading through quite a bit.
Bob Arctor · 2019-09-26 05:14
Some of you might find this interesting: https://github.com/hundredrabbits/Ronin https://www.youtube.com/watch?v=SgAWGh1s9zg