From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Cowan Newsgroups: gmane.lisp.guile.user Subject: Re: guile-json 2.0.0 released Date: Wed, 19 Dec 2018 15:05:30 -0500 Message-ID: References: <87y38meqbo.fsf@gnu.org> <87lg4lzt9l.fsf@gnu.org> 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 1545249851 9314 195.159.176.226 (19 Dec 2018 20:04:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2018 20:04:11 +0000 (UTC) Cc: =?UTF-8?Q?Ludovic_Court=C3=A8s?= , guile-user To: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Dec 19 21:04:06 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 1gZi4c-0002JY-1u for guile-user@m.gmane.org; Wed, 19 Dec 2018 21:04:06 +0100 Original-Received: from localhost ([::1]:33965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZi6i-0002ST-Js for guile-user@m.gmane.org; Wed, 19 Dec 2018 15:06:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZi6H-0002SA-LS for guile-user@gnu.org; Wed, 19 Dec 2018 15:05:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZi6F-0007UM-RX for guile-user@gnu.org; Wed, 19 Dec 2018 15:05:49 -0500 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:55296) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZi6D-0007T6-KE for guile-user@gnu.org; Wed, 19 Dec 2018 15:05:46 -0500 Original-Received: by mail-wm1-x335.google.com with SMTP id y139so7248113wmc.5 for ; Wed, 19 Dec 2018 12:05:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HYLVEtynwWWBqMmSGAW735lJU2z4BnViEHyv4wGux+A=; b=K5ZUsNo1/3xedlPkF8gTgOHa9qAL74PnvfUBTQt8EjhX3jeR99OJs27AAUAl/4CW0E dm3muIavSfALVMP/hNRP03OOcUHx+A+vKPXMR+cEv+BM0zhSVMyTMpcBoJPf8yirrSlR pN8474v7P9/wc9wFvk4bJOLWRe4a6L1jIRa2dVyh6erKdR7VyKX68so0U31jKZZeLr4b WmVQiFaXmkdsf6jMSnoDdKMlJ9JA5t6zP0u7u+l5oO1mt3VrXmBd54+ul2S/wUHm8DVl Ij2ywKPYmyH5vrN2bPiG2eO7I9GK3z5Y1127klLqhE0ZxHCKhPLlA6CHt2votn8PT6WD W1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HYLVEtynwWWBqMmSGAW735lJU2z4BnViEHyv4wGux+A=; b=VClteLdBuBxqMrDmoS72rSuyl4ThRwfruiNmycRk2wmMI26BNFVce/xMcsUsMCPw4W CFKpygLrV2/oAeZEgh+xNvbXQod6NHihpjQeg9MNn9B1jbFBkLjk4TcuTTxWECupACVT HyT1shZrKu1Kr2z8PyWLJkWlkPP18MwB4fdpVhIhr+LYq4AKObhaZF2u3scehbrevW5C MyJkwQIUe4M9caZroJaqEBBNrT3W1witFuyhWUKlNjNU7Ps5yRaSAoNJtexhzLo4T2Tq ruVhIvywzFLwgQLKs8skEI9qWPHGCRX71ejg+YN3YDsmeIYgyGr9xQdP1LSep6c8ArVv YHIg== X-Gm-Message-State: AA+aEWa1kNIuh1VZz/u3YWEOn4ND4hTA1sL4GdHPok3+KansRf8mS75F imypPBtnNIzjsIOPX63XIEUCbu60jDd6+qrQWAeJ8w== X-Google-Smtp-Source: AFSGD/UCngKCO523OMbL0MZQKWop8sfUHUKZ6qxUHs7p2wuYyL3RuWMRedvlKtyEkSUwp6rRqOecOpBRb4CGxed3YTw= X-Received: by 2002:a1c:38c4:: with SMTP id f187mr8201504wma.90.1545249942269; Wed, 19 Dec 2018 12:05:42 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:15132 Archived-At: On Wed, Dec 19, 2018 at 1:16 PM Aleix Conchillo Flaqu=C3=A9 wrote: So, I'm really considering switching to alists for objects and vectors > for arrays. > I still favor the other way about: lists for arrays, avectors for objects, because arrays are typically varying in length and objects are mostly not. ;; Here are a few helpful (but untested) procedures ;; which are in the public domain de minimis (but I will sign ;; a contributor agreement if needed): (define (alist->avector alist) (let* ((len (length alist)) (vec (make-vector len))) (let loop ((i 0) (alist alist)) (when (not (null? alist)) (vector-set! vec i (car alist)) (loop (+ 1 i) (cdr alist))) vec))) (define (avector->alist avec) (let ((len (vector-length avec))) (let loop ((i 0) (alist '())) (if (=3D i len) (loop (+ i 1) (cons (vector-ref avec i) alist))) (reverse alist)))) (define vector-assoc (case-lambda ((key avec) (vector-assoc key avec equal?)) ((key avec pred) (let ((len (vector-length avec))) (let loop ((i 0)) (cond ((=3D i len) #f) ((pred key (car (vector-ref avec i))) (vector-ref avec i)) (else (loop (+ i 1)))))))))