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: What should the constructor for a record look like? Date: Sun, 26 Aug 2018 15:04:44 +0200 Message-ID: <1617672.9nuLs2ACSm@aleksandar-ixtreme-m5740> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: blaine.gmane.org 1535292422 32042 195.159.176.226 (26 Aug 2018 14:07:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Aug 2018 14:07:02 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 26 16:06:58 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 1ftvgs-00086j-1U for guile-user@m.gmane.org; Sun, 26 Aug 2018 16:06:54 +0200 Original-Received: from localhost ([::1]:49202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftviy-0005Z9-CC for guile-user@m.gmane.org; Sun, 26 Aug 2018 10:09:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftuip-00067A-4U for guile-user@gnu.org; Sun, 26 Aug 2018 09:04:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ftuil-0004Go-Vz for guile-user@gnu.org; Sun, 26 Aug 2018 09:04:51 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:34021) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ftuil-0004FV-D0 for guile-user@gnu.org; Sun, 26 Aug 2018 09:04:47 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id B9DD120F54 for ; Sun, 26 Aug 2018 15:04:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1535288685; bh=jCjnO0fvqjsXlAB0G7TqmMiRWlaBN4xh+7AN92zv2WI=; h=From:To:Subject:Date:From; b=QGnpVcXu2y/Ha3tNvLgCPNlbDc5JLn8R0M+Zu6ZiyYIups3ypxEsYhR9W+I+foE3P L0K+kwu3TS3AgHwXOl22GD9LBgtWeJocoXC86WivWnr4fVfr3C7JSRKv5mUK6Zel1Z FKScsuEuvz0VxHTL5yN69Hi5DbKAyPZTNlPeQ+gY0jSTYavHpMvGNx3+BX8cMf8hsK 1ydta5l+X6i3T6B/nrrL9Y5OH0e/LuMLY5UIXL3CkoJmdYSOL7u3ouif2xVFfp6P56 c+6b0hc1YAk8W6MDZ7I70U6pgxu4E4SGxzoS8xLcyF6tuf31M4B+/SAIaUvuc6TvwJ Rz3uTO8xsCXDQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 41ywGP0Pkqz9rxN for ; Sun, 26 Aug 2018 15:04:44 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.67.36.66 X-Mailman-Approved-At: Sun, 26 Aug 2018 10:07:48 -0400 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:14758 Archived-At: Hello, it's me again, the guy who wants to implement MessagePack [1] in Guile. The specification defines a type of "extension" [2], a pair of an 8-bit integer and a byte array for data. Implementing this type as a record is obvious, but what should be the name of the constructor? (define-record-type ext (make-ext type data) ext? (type ext-type) (data ext-data)) Either `make-ext` or just `ext` seem appropriate. I have seen both types of constructors, what do you guys say? And while I'm on the topic, what about types? An extension is only valid if the first field (type) is an integer from -128 to 127 and the data a vector of bytes (integer in the range from 0 to 255). How do I enforce this invariant without static typing? [1] https://msgpack.org/ [2] https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family