From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Bytestructures: a "type system" for bytevectors Date: Tue, 08 Sep 2015 09:59:50 +0200 Message-ID: <87lhch8hop.fsf@T420.taylan> References: <87r3mkg2iy.fsf@T420.taylan> <8737yzftyv.fsf@T420.taylan> <20150907225711.5701711.51285.15525@ossau.homelinux.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1441699207 29933 80.91.229.3 (8 Sep 2015 08:00:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Sep 2015 08:00:07 +0000 (UTC) Cc: guile-user@gnu.org To: neil@ossau.homelinux.net Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Sep 08 10:00:06 2015 Return-path: Envelope-to: guile-user@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 1ZZDoy-0002tA-95 for guile-user@m.gmane.org; Tue, 08 Sep 2015 10:00:04 +0200 Original-Received: from localhost ([::1]:60593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZDox-0001RN-SR for guile-user@m.gmane.org; Tue, 08 Sep 2015 04:00:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZDoo-0001PL-Pk for guile-user@gnu.org; Tue, 08 Sep 2015 03:59:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZDon-00009R-OU for guile-user@gnu.org; Tue, 08 Sep 2015 03:59:54 -0400 Original-Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:35265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZDon-00007m-HT for guile-user@gnu.org; Tue, 08 Sep 2015 03:59:53 -0400 Original-Received: by wicge5 with SMTP id ge5so105836809wic.0 for ; Tue, 08 Sep 2015 00:59:51 -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=+3VXwTVk4nZCnQSxpYjXiHaw8QkTQq7RrKc7WPJrk78=; b=kKKpPbCy/yGJ8quQK2mhHwsSH2vJL6qix7LYjGhycRyqPlZgpr+5L0yOQJnmgclayI 1Ua9kmJ5sQIq7vAl6URymDEEhMM3jfjAhbDNEhOlqRUMSmWyucEJ1tzTttcZ6NV9CjpG pYrA3E856jfJ3bpR0eKtxiVHN9I4x0AivIbvpoYzGXUBkTJNGED6rdcYqSk52eJwb040 pnS5cN0srBux3A+gWUVfpTxWWNBBzeWJpZuhL/bC9b/H4sxXPou4/macBuz3DSSRtfM5 D+5Pxh9kUfuKUWpuK4RxuaDdT2a3Zd42SLrACgL9LFWfi4onxFLGWQB0Xwt7LXi+nYeY ppBQ== X-Received: by 10.194.113.170 with SMTP id iz10mr43815172wjb.58.1441699191752; Tue, 08 Sep 2015 00:59:51 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id fs9sm3352471wic.24.2015.09.08.00.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 00:59:50 -0700 (PDT) In-Reply-To: <20150907225711.5701711.51285.15525@ossau.homelinux.net> (neil@ossau.homelinux.net's message of "Mon, 07 Sep 2015 23:57:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::233 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12005 Archived-At: neil@ossau.homelinux.net writes: > Sorry for not mentioning this before, but have you seen make-c-struct > and parse-c-struct at > https://www.gnu.org/software/guile/manual/html_node/Foreign-Structs.html > ? Yup. They're somewhat primitive, not supporting nested structs or arrays. Unions aren't supported at all. Bytestructures imitates C's type system in full w.r.t. numeric, array (vector), struct, union, and pointer types. Though there are two main missing things now: tight packing and bit fields. Tight packing should be simple to implement by allowing an integer for the optional argument to the struct constructor (currently only accepts #f to mean no alignment-padding whatsoever, and #t (the default) for conventional packing). Bit fields would be implemented by allowing an optional third element, the width, in each field of the fields alist passed to the struct constructor. The only problem is how to implement fields smaller than 8 bits when the bytevector API only allows granularity down to 8 bits. I guess it would be implemented via bitwise operations or by converting ints to bit-arrays. In any case it shouldn't be too hard to abstract it out entirely for the user. I'm working in a couple other things in parallel, but I should find time to implement those some time in the not too distant future. Taylan