From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: HiPhish Newsgroups: gmane.lisp.guile.user Subject: A macro containing a mini-macro? Date: Fri, 14 Sep 2018 00:04:04 +0200 Message-ID: <2093628.1NtSHukUaa@aleksandar-ixtreme-m5740> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1536876369 14931 195.159.176.226 (13 Sep 2018 22:06:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Sep 2018 22:06:09 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Sep 14 00:06:04 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0ZkS-0003lP-HM for guile-user@m.gmane.org; Fri, 14 Sep 2018 00:06:04 +0200 Original-Received: from localhost ([::1]:44502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0ZmY-0000WJ-Tr for guile-user@m.gmane.org; Thu, 13 Sep 2018 18:08:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0Zm8-0000U1-IR for guile-user@gnu.org; Thu, 13 Sep 2018 18:07:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0Zlk-0004UD-7V for guile-user@gnu.org; Thu, 13 Sep 2018 18:07:35 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:53463) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0Zli-0001y6-TO for guile-user@gnu.org; Thu, 13 Sep 2018 18:07:23 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id D660720DE4 for ; Fri, 14 Sep 2018 00:04:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1536876246; bh=3ngsdjiJ5PptRE50s2JOcDFFBCwOqE5Xr1pkyRZINog=; h=From:To:Subject:Date:From; b=b7TsYWpUtGGExEq5w+w5JqRxpq8QGNaTUeOtb/Av55Eujc6DLwi88DtNze9DgFh9x ZN0jxMrZqNGt0VpkJdHVo/2nwuUhGKsDyiQhh4sjFX009DRZ5iPV0L4gZPJjgnAWqG DkH3+jX58QDlsz0y+puVACL7wn5ThGWsrnBNILFxTeXT7oOCm3j5BlEZs1rav7OdmE mD73Za/gk8kk6+AjsdRDZNVISR0gOca7x+u+KuUDOjfaNUKCgMyNeMmQpXPMYZycJ6 Sz3/tC4YuwVe09RBoUEi9JoXNyExYu5UkUHRsVvUK+ZLj4lyPzpmPBXR9UqebLFEIG Pp8CyMiaQkSiw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 42BCNQ0fkYz6tm5 for ; Fri, 14 Sep 2018 00:04:05 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.67.36.65 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14873 Archived-At: Hello Schemers, I have written a small macro for writing test specifications: (define-syntax test-cases (syntax-rules () ((_ title (given (byte byte* ...)) ...) (begin (test-begin title) (call-with-values (=CE=BB () (open-bytevector-output-port)) (=CE=BB (out get-bv) (pack given out) (let ((received (get-bv)) (expected (u8-list->bytevector '(byte byte* ...)))) (test-assert (bytevector=3D? received expected))))) ... (test-end title))))) The idea is that I can specify a series of test cases where each case consi= sts=20 of an object and a sequence of bytes which this object is to be serialized = to: (test-cases "Single precision floating point numbers" (+3.1415927410125732 (#xCA #b01000000 #b01001001 #b00001111 #b1101101= 1)) (-3.1415927410125732 (#xCA #b11000000 #b01001001 #b00001111=20 #b11011011))) This works fine, but sometimes there is a sequence of the same bytes and it= =20 would be more readable if I could write something like this: ((make-vector 16 0) (#xDC (16 #x00))) instead of writing out 16 times `#x00`. This would require being able to ma= ke=20 a distinction in the pattern whether `byte` is of the pattern byte or (count byte) and if it's the latter construct a list of `count` `byte`s (via `(make-list= =20 count byte)` for example) and splice it in. This distinction needs to be ma= de=20 for each byte specification because I want to mix actual bytes and these "R= LE- encoded" byte specifications. So I guess what I'm looking for is to have a `syntax-rules` inside a `synta= x- rules` in a way. Can this be done?