freenode/#lisp - IRC Chatlog
Search
16:51:15
vms14
there is no directive in format to print the current number of iterations inside a list?
16:53:53
White_Flame
isn't there a format escape that will evaluate a form? can you shove an INCF in there?
16:59:08
pfdietz
In which I discover both Optima and Trivia can take exponential time to compile a pattern.
17:03:07
pjb
vms14: (format nil "~2,1@/fmt-index/~:*~{~,/fmt-index/~:* ~(~A~)~^~%~}." '("rule 1" "rule 2")) #| --> "1 rule 1 ; 2 rule 2." |#
17:05:23
White_Flame
an easier-to-write but less memory efficient version would be to map* up a list of data with calculated counters in it, then pass that to FORMAT
17:05:43
dlowe
(loop for e in list as i from 0 do (format t "~a. ~a~%" i e)) seems more than reasonable
17:06:46
pjb
Remember that the control string is an argument to format. It can come from a configuration file or a localization file.
17:08:17
vms14
but it's an interesting case and a good example to learn how to create functions for format
17:40:48
White_Flame
one of the more interesting output construction facilities I've seen is in Erlang
17:41:12
vms14
and I thought it could be a good exercise for a noob like me to create a lisp version of this script
17:41:21
White_Flame
you build up nested lists of strings (or byte values), and then the final output call loops through, flattening all the output into the stream
18:52:39
aeth
the only problem with format is that there isn't a (standard) deformat for parsing so you could (stream "~F" variable) and get a variable out
20:07:51
pjb
aeth: format is quite complex, with ~{ an ~/; it would be difficult to write a symetric scan function.
21:24:10
Bike
So writing (code-lambda-list (+ 3 2) (format t "oh")) is equivalent to writing (list (lambda () (+ 3 2)) (lambda () (format t "oh")))?
21:24:37
Bike
That's what you need to convey in your example and think about when you're writing a macro. The expansion.
21:25:42
Bike
Don't think in terms of backquoting, think in terms of inputs and outputs. You're just constructing a form.
21:33:09
Bike
(defmacro code-lambda-list (&rest forms) `(list ,@(loop for form in forms collect `(lambda () ,form)))) is how i'd write it. no ,@ of the forms.
21:45:14
Bike
(defmacro code-lambda-list (&rest forms) (cons 'list (loop for form in forms collect (list lambda () form)))) works too.
21:45:47
vms14
(dolist (oh (list "oh" "my" "cat")) (push `(lambda () ,oh)) flist) why this isn't working
21:46:31
Bike
I get an error like "Too few arguments supplied to a macro or a destructuring-bind form", don't you?
21:48:30
Bike
(defmacro code-lambda-list (&rest forms) (cons 'list (let ((elems nil)) (dolist (form forms (nreverse elems)) (push (list 'lambda () form) elems)))))
22:01:03
vms14
I have a function that associates options with functions and calls a function depending on the option the user chooses
22:03:18
vms14
now I can just (show-menu '("option1" "option2") (code-lambda-list (print "option1") (print "option2")))
22:36:21
teeeay
might be the wrong place to ask, but does anyone here have any experience with the vecto library for common-lisp?
0:30:06
vms14
Shinmera: can you point/recommend some lisp web libraries? not just your own ones, but stuff you find is useful for web development
0:33:26
patrixl
I've used Radiance extensively, other accompanying libraries I've made the most use of also are:
0:35:17
patrixl
yason for json parsing/emitting, spinneret for handling html, plump for xml/html parsing...
0:36:13
vms14
and It's not the first time I found a lisper who does not like cl-who for some reasons
0:36:23
patrixl
oh yeah I tried a few.. started out with cl-who at first, used r-clip as well, for now I settled on Spinneret
0:36:56
patrixl
cl-who is alright, I think it's when you want to do more complex things that you start writing macros, so might as well use something like spinneret that can help out
0:37:10
vms14
I've looked at cl-css, it's fine. Also looking at Shinmera's LASS library which seems much nicer
0:37:18
patrixl
basically I wanted to define my own "tags" so simplify my code and remove a lot of repetitions
0:38:09
patrixl
so it was either write a bunch of macros with cl-who, and learn a bunch of lessons over time leading me to rewrite my macros.. or use spinneret that already has gone through that process lol
0:39:50
mfiano
He goes as far as to recommend alternatives in his book, Common Lisp Recipes. He told me I should use them in email correspondence
0:52:55
mfiano
That's because it's ruricolist's project, and he wrote and uses serapeum everywhere, which has almost 40 dependencies itself
0:57:59
patrixl
and thinking "40 deps isn't as bad as any npm package" and then berating myself for thinking like that
0:58:52
aeth
What's going to become my utility library has essentially no dependencies except for alexandria and maybe a few more.
1:00:53
aeth
For CSS, well, CSS is much harder than HTML because it has this weird regexp-like language for selectors
1:01:19
mfiano
javascript has more dependencies because they have libraries for the most basic of tasks. there are such things as 1-line libraries. In a way this is better, but it does result in downloading the whole internet for a trivial project. I am of the opinion that utility libraries are rather useless when they bring in so much functionality that you don't need. Just copy what you need into your project and move on.
1:01:38
aeth
I thought I had a feature list, then I realized each feature has features, and I shelfed my CSS selector DSL for another day... again.
1:02:39
aeth
Well, I allow strings as selectors and always will because there's a good chance I'll accidentally leave features out
1:08:14
vms14
I want to practice with microdata and I saw it's very easy to put microdata for a qa page
1:08:54
vms14
google should show the answered question in a more visible way using microdata, stackoverflow uses microdata, quora does not
1:10:57
vms14
a forum has more needs than what I thought, I'm using phpbb as example to see what a forum should have. I see it uses templates for html with some little dsl inserted in it
1:11:28
vms14
It seems to be an interesting exercise to create a forum, but I'm really aiming to create a forum creator
1:12:09
vms14
should be a good step for then creating a website creator, a forum has more specific stuff, so it should be easier
1:12:32
aeth
phpBB offers a lot more than you probably need to offer for an initial first attempt at a web app
1:12:58
vms14
aeth: yes, but it serves as a good example and I can look at their features and steal them slowly
1:20:11
aeth
Running a forum (or wiki or whatever) on the Internet isn't really about the visible feature set, it's about the invisible issues that are practically mandatory, like moderation tools and anti-spam measures.
1:22:06
aeth
If you just have a submit box on the Internet, bots will flood it. Especially if it's known software like MediaWiki or phpBB, but I assume it will apply to custom forums as well.
1:23:09
aeth
If you want others to use it, you could have an IRC bot here give people a secret registration link. Security by obscurity, nobody's going to think to use an IRC bot.
1:23:34
aeth
Otherwise you're going to have to think about how to combat spam accounts far too much and that'll be all you think about.
1:49:32
no-defun-allowed
Because then if you have a name like John Where, you now store John. That sucks.
1:50:31
no-defun-allowed
I think any SQL libraries in CL with a s-expression syntax (or most SQL libraries in any language with some special function) will escape for you though.
1:54:42
aeth
xkcd 327 is old enough (2007-10-10) that if anyone did name a kid that name, then that kid could turning 12 in a few days. https://www.explainxkcd.com/wiki/index.php/Little_Bobby_Tables
1:55:40
aeth
take a few years to develop your software and Bobby Tables could literally be using your forum software
2:01:13
aeth
The article for the comic at [1] recommends to use prepared statements [2]. [1] https://www.explainxkcd.com/wiki/index.php/327:_Exploits_of_a_Mom [2] https://en.wikipedia.org/wiki/Prepared_statement