From nikodemus at random-state.net Mon Jul 7 05:15:26 2008 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Mon Jul 7 05:15:34 2008 Subject: [alexandria-devel] Re: Review cycle 2: SWITCH, ESCWITCH, and CSWITCH In-Reply-To: <87hcc02d16.fsf@freebits.de> References: <633d72b0806070412v354df6abl15e64cc7676fd79c@mail.gmail.com> <633d72b0806070430pec6cbbey9c78df252d175d6@mail.gmail.com> <633d72b0806081513p25dfcc01vdb0530039bbbbf5@mail.gmail.com> <87hcc02d16.fsf@freebits.de> Message-ID: <633d72b0807070215n492928dcp541f554b4294a70b@mail.gmail.com> On Wed, Jun 11, 2008 at 6:43 PM, Tobias C. Rittweiler wrote: > "Nikodemus Siivola" writes: > >> Re. expanding into COND: I think the API is the important bit. If we >> are able to figure out that something else is more efficient, then we >> can expand into something else -- COND is an implementation detail. > > It isn't about expanding into COND per se, but that the clause-keys are > evaluated. Both behaviours are useful, but the name SWITCH connotes the > non-evaluating behaviour, IMO. We could add another macro that works > like SWITCH works now, but is called SELECT. On reflection, I think you are right. Here's my next take (same docstring for all three.) "Conditionally executes one of the clauses, and returns its values. Clauses are of the form: (CLAUSE-KEYS &BODY FORMS) CLAUSE-KEYS is a designator for a list of objects. Symbols T and OTHERWISE may not be used as the CLAUSE-KEYS designator: to refer to these symbols by themselves as CLAUSE-KEYS, designators \(T) and \(OTHERWISE) must be used. KEYFORM is evaluated to produce a comparison value. Each of the CLAUSES is the considered in turn. If (MEMBER 'CLAUSE-KEYS-LIST :TEST TEST :KEY KEY) is true, the FORMS in that clause are evaluated as in implicit PROGN, and the values returned as the value of the SWITCH, CSWITCH, or ESWITCH form. Clauses with T or OTHERWISE as CLAUSE-KEYS are considered to always match. Such clause must be tha last clause. If no clause matches, SWITCH returns NIL, CSWITCH signals a continuable error, and ESWITCH signals an error." Cheers, -- Nikodemus From nikodemus at random-state.net Mon Jul 7 05:55:21 2008 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Mon Jul 7 05:55:27 2008 Subject: [alexandria-devel] Pushed Message-ID: <633d72b0807070255r315ffe4bh419674b07cf6749e@mail.gmail.com> Mon Jul 7 11:51:14 EEST 2008 Nikodemus Siivola * implement SIMPLE-PROGRAM-ERROR ...what is says on the tin. Mon Jul 7 11:55:06 EEST 2008 Nikodemus Siivola * implement PARSE-ORDINARY-LAMBDA-LIST ...not something you need every day. Mon Jul 7 11:57:04 EEST 2008 Nikodemus Siivola * implement MAKE-GENSYM, use similar logic in MAKE-GENSYM-LIST ...non-negative integers are arguments, and string designators instead of strings. Mon Jul 7 12:50:26 EEST 2008 Nikodemus Siivola * explicitly export the CDR5 types from DEFPACKAGE ...so reloading package.lisp doesn't warn. Cheers, -- Nikodemus From tcr at freebits.de Mon Jul 7 06:17:53 2008 From: tcr at freebits.de (Tobias C. Rittweiler) Date: Mon Jul 7 06:18:09 2008 Subject: [alexandria-devel] Re: Pushed References: <633d72b0807070255r315ffe4bh419674b07cf6749e@mail.gmail.com> Message-ID: <87prpqov5a.fsf@freebits.de> "Nikodemus Siivola" writes: > Mon Jul 7 11:55:06 EEST 2008 Nikodemus Siivola > * implement PARSE-ORDINARY-LAMBDA-LIST > > ...not something you need every day. I often lament about the lack of operators for lambda-list frobbing in the standard, but I think there should be a standalone library for this, and more lambda-list-fu. -T. From tcr at freebits.de Sat Jul 12 13:06:56 2008 From: tcr at freebits.de (Tobias C. Rittweiler) Date: Sat Jul 12 13:07:21 2008 Subject: [alexandria-devel] Sequence Iterators. Message-ID: <8763rb1173.fsf@freebits.de> Hi all, When writing complex functions that are supposed to work on sequences, one often laments about the lack of an iteration form that works on general sequences. I finished my work on sequence iterators to provide several abstractions to help writing such functions. The iterators are reasonably optimized, and result in performance that should be fast enough for virtually any purpose, especially on SBCL. The iterators are not extensible by any means, and only work on lists and vectors. My work provides the following macros: (with-sequence-iterator (name seq &key start end from-end) ...body...) Binds NAME to an iterator to iterate through SEQ from START to END, possibly in reversed order if FROM-END is T. (dosequence ((var idx) seq &key start end from-end) ...body...) Iterates through SEQ, binding VAR to the current element, and IDX to the current index of the current element. (dosequences (((var idx) seq &key start end from-end) &rest more) ...body...) Iterates through several sequences simultaneously. (dosequences* (((var idx) seq &key start end from-end) &rest more) ...body...) Similiarly to DOSEQUENCES, but iterates through the sequences in a more sequential manner. Cf. its docstring. (check-sequence-bounds seq start end &optional length) Signals an error if START, END are not valid bounding indices. (with-sequence-bounds ((seq-var seq) (start-var start) (end-var end) (length-var length)) ... body ...) Wrapper around CHECK-SEQUENCE-BOUNDS to bind the above vars to appropriate default values, check validity of indices, and declare some types. It can be found in my repository at http://common-lisp.net/~trittweiler/darcs/alexandria/ As a schmankerl (tidbit), here is an implementation of a function which tests whether a given sequence is the prefix of another given sequence: (defun begins-with-subseq (prefix sequence &key (test #'eql) (key #'identity) start1 end1 start2 end2) "Test whether the first elements of SEQUENCE are the same as the elements of PREFIX." (dosequences* ((p prefix t :start start1 :end end1) (s sequence nil :start start2 :end end2)) (unless (funcall test (funcall key p) (funcall key s)) (return nil)))) I hope you enjoy, -T. From tcr at freebits.de Sat Jul 12 13:10:47 2008 From: tcr at freebits.de (Tobias C. Rittweiler) Date: Sat Jul 12 13:15:05 2008 Subject: [alexandria-devel] Re: Sequence Iterators. References: <8763rb1173.fsf@freebits.de> Message-ID: <871w1z110o.fsf@freebits.de> "Tobias C. Rittweiler" writes: > > (dosequence ((var idx) seq &key start end from-end) > ...body...) This macro (and the DOSEQUENCES) also take an &optional result argument as third parameter. -T. From luismbo at gmail.com Sun Jul 27 18:14:08 2008 From: luismbo at gmail.com (Luis Oliveira) Date: Sun Jul 27 18:14:29 2008 Subject: [alexandria-devel] Testing with Lisps other than SBCL, patches Message-ID: <87hcabug9b.fsf@deadspam.com> Hello, Yesterday I decided to test Alexandria with a couple of Lisps. The following patches resulted from that session, except MULTIPLE-VALUE-PROG2 whose usefulness is admittedly debatable. Sun Jul 27 04:01:39 WEST 2008 Luis Oliveira * Mark expected failures for Allegro CL: TYPE=.[234] Sun Jul 27 04:01:30 WEST 2008 Luis Oliveira * amend COPY-SEQUENCE.1 - can't assume that (upgraded-array-element-type 'fixnum) => fixnum. Fix that. Sun Jul 27 03:54:27 WEST 2008 Luis Oliveira * tests: mark CLISP failures - COPY-HASH-TABLE.1 causes a stack overflow due to a CLISP bug. - ALIST-HASH-TABLE.1, PLIST-HASH-TABLE.1 fail because HASH-TABLE-TEST returns EXT:FASTHASH-{EQ,EQL}. Sun Jul 27 03:46:35 WEST 2008 Luis Oliveira * tests: define and use ERRORP - TYPEP returns a generalized boolean. On Lisps like ECL, this detail was causing some tests to fail. ERRORP takes this into account. Sun Jul 27 03:45:07 WEST 2008 Luis Oliveira * Small fix to COPY-HASH-TABLE - New hash-table was being created with a bogus rehash-size. - Added regression test in another patch. Sun Jul 27 03:43:21 WEST 2008 Luis Oliveira * Define an alexandria-tests ASDF system. - make it usable for other Lisps besides SBCL. - TEST-OP runs tests both compiled and evaluated. Sun Jul 27 03:37:13 WEST 2008 Luis Oliveira * New macro: MULTIPLE-VALUE-PROG2 These patches can be pulled via darcs pull http://common-lisp.net/~loliveira/darcs/alexandria -- Lu?s Oliveira http://student.dei.uc.pt/~lmoliv/