From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: Question on pcase Date: Fri, 23 Oct 2015 14:42:20 +0200 Message-ID: <87ziz9dadv.fsf@gmail.com> References: <871tcngdv2.fsf@gmail.com> <87k2qe1u09.fsf@web.de> <83r3kmrtat.fsf@gnu.org> <87k2qdeqym.fsf@gmail.com> <87lhat22pv.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445604138 3574 80.91.229.3 (23 Oct 2015 12:42:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2015 12:42:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 23 14:42:17 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZpbfY-0004KJ-NA for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 14:42:04 +0200 Original-Received: from localhost ([::1]:38220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpbfX-0006WH-VS for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 08:42:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpbfU-0006UW-Pt for emacs-devel@gnu.org; Fri, 23 Oct 2015 08:42:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpbfP-00009S-1J for emacs-devel@gnu.org; Fri, 23 Oct 2015 08:42:00 -0400 Original-Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:37411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpbfO-00009C-SZ for emacs-devel@gnu.org; Fri, 23 Oct 2015 08:41:54 -0400 Original-Received: by wicfv8 with SMTP id fv8so30218851wic.0 for ; Fri, 23 Oct 2015 05:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=5Us3PgBYcZPDdE9E+zjZ13rex+vQz4xis9SPT64hZPU=; b=HXr2m0WGc0aLeG+fCU8aBk3tH4AQPAKWtJWqrYJVaE99F13UPBBWBE6jxuZJ4JvqNv q8+2c5MuoT2Wy1NM+EGhu74TbjxKA3Ku8tnun2uUJ3NOsZKr6NQc6E4DCZ3vKc8ztiI/ 7253FX76mN7hlMTNUUIOmw7kvdt2fmJsCJCkZURafPc5fJSYok2Ve+mFNDGBFZC1pcFS ePo3ZAmoUbOd30nGHrhh251pATFRjXGmRyfS7vT/n1GEKK2LsrNp+XbCgAVYscRFMIq5 sa/qO2+c64VqScR1B2P/G+M0fTPcmPRnUgpAFPN0kk6oePbLEM34DYIdBB2iSe9BMsu/ 7zow== X-Received: by 10.180.36.193 with SMTP id s1mr4558384wij.46.1445604114319; Fri, 23 Oct 2015 05:41:54 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id gl9sm22521885wjb.10.2015.10.23.05.41.52 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Oct 2015 05:41:52 -0700 (PDT) In-Reply-To: <87lhat22pv.fsf@web.de> (Michael Heerdegen's message of "Fri, 23 Oct 2015 14:23:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192481 Archived-At: Michael Heerdegen writes: > I guess you might like something like this: > > (defun pcase-demystify-pattern (pattern) > (pcase--u > `((,(pcase--match '-tested-expression- (pcase--macroexpand pattern)) > ,(lambda (vars) `(progn ,@(mapcar (lambda (b) `(-bind- ,(car b) ,(cdr b))) > vars))))))) > > You need to quote the pattern because this is a function. > > (pcase-demystify-pattern '`(,_ . ,(and (pred functionp) f))) > > ==> > > (if > (consp -tested-expression-) > (let* > ((#1=#:x > (cdr -tested-expression-))) > (if > (functionp #1#) > (progn > (-bind- f #1#)) > nil)) > nil) Thanks Michael, that's almost exactly what I need. The only thing is that I don't understand what `-bind-' is.