all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: 16201@debbugs.gnu.org
Subject: bug#16201: 24.3.50; error expanding pcase with a pred clause
Date: Sat, 21 Dec 2013 12:54:21 +0100	[thread overview]
Message-ID: <87eh568ln6.fsf@web.de> (raw)
In-Reply-To: <87txe3h98p.fsf@web.de> (Michael Heerdegen's message of "Fri, 20 Dec 2013 15:45:10 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:


> (defun test-buffer-file-name ()
>   (pcase buffer-file-name
>     (`nil                   'not-a-file)
>     ((pred file-writable-p) 'writable)
>     (_                      'not-writable)))
>
>   pcase-bug.el:3:1:Error: Wrong type argument: stringp, nil

pcase seems to test whether the constant (nil) from the first clause
fulfills the pred of the second clause.  Which is not legal in this
case.

I thought this could be ok:

(pcase buffer-file-name
    (`nil                   'not-a-file)
    ((and (pred stringp)
	  (pred file-writable-p)) 'writable)
    (_                      'not-writable))

but that triggers the same error.

This works, however, but doesn't look so nice:

  (pcase buffer-file-name
    (`nil                   'not-a-file)
    ((pred (lambda (x) (and (stringp x) (file-writable-p x)))) 'writable)
    (_                      'not-writable))


Regards,

Michael.





  reply	other threads:[~2013-12-21 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 14:45 bug#16201: 24.3.50; error expanding pcase with a pred clause Michael Heerdegen
2013-12-21 11:54 ` Michael Heerdegen [this message]
2014-01-03  4:41 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh568ln6.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=16201@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.