From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 0F9A722392 for ; Thu, 18 Jan 2024 17:24:55 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705595095; b=VGYq6phfRGv+1CNVpkfeyidqCWpYmCxMwZN0U9hJzy1fOxy6rDatr7sESi4bp7IlRx8zJ0323q FG3N/OfExws0cTfi3Lwmz8rHdQ0JTch1U2YWLOfaA1CgrShK638OBkRPp7M0V6MTPlsYo238zR C1htUqxxz31pdj+5IiNModAKOxcddYgAAM5IX0huZyhznt2ooAKlVIg8l8qr7JcnQX5KSfGKmW KLSs3t5/Nvtvqh7BeEYUnNHIpbX51k8VmGslJZTYGQGq/afUHqkh5pCEaZ+/p3KPn97hPzDXeZ kAEPARLAcUeF5cWn7gMz/1SkxVBIVXvUZBMIq1ICr0ZEtg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f173.google.com) smtp.remote-ip=209.85.208.173; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1705595095; bh=bgC7laYDhcy/d0aRJ1ysrFusf7tOC86i0x04lkEFoVs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=CyrCI7Gyk0PFJv8tvJiYFwq5jBEcz61pNmmCNuS9W/2z1SP3ZS9C+sktxnwtsxzmIiPCcV3SUf 6anZOr0+f83kZ9/F1PPednXVNLeNpxObWORW9zoQdZp5txNlXry/i6JANstb4X+cos75YDsrIs Ju5diPlSOZ1wKHMUDqaqqyKUM2/mXHk2+5RKgZkuT1NBoOcSXMbbHGRyrIzKW/ctLTcKtim2T0 b1wHCq5IsQfeuXhIPS2UUdrY6XhH8HccesN4zA1gxlZbS4Rdbq3nEEVUI/PnTlG10T3LEXjtq4 6z8BmQqFsH8G58PvwybgHf5wk2hec+SCWB7PpgnstOpYIA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bgC7laYDhcy/d0aRJ1ysrFusf7tOC86i0x04lkEFoVs=; b=nH4n+jOH2W7z+7rRfXkX3CSSTu Hjp3w56uayCrd2oBtPZ5EuuKhknDPGnRj9m93hOFFmr44IalLkRkLbZvebGTZNMOSHpBmredH3PPc DMhhKS4Hapd5V1yOPoLcscQ0yaJYnui6u/41SeEJFNt6kWf8giCQLRvzUwQRew8PLprQVHT65/ub6 W7OKvlRgh35/xUW1+32qel9X0e+PY6WisKlf7mesRE/uQt9Z+cWGFHFp9yA5SYJdW9OurA0jhdGhs 8p7novRqaM2OX/LqImEeGnhv2ZYc7mjxVRWvsjwJU/tn6958gb+UT3SuHua9pBDbLqDtRTea8/hf0 ito7paIg==; Received: by zero.zsh.org with local id 1rQVCJ-000B6A-H2; Thu, 18 Jan 2024 16:24:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f173.google.com) smtp.remote-ip=209.85.208.173; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f173.google.com ([209.85.208.173]:54571) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rQV7z-000ACo-Kh; Thu, 18 Jan 2024 16:20:28 +0000 Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2cdebb968feso25434981fa.1 for ; Thu, 18 Jan 2024 08:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705594826; x=1706199626; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=bgC7laYDhcy/d0aRJ1ysrFusf7tOC86i0x04lkEFoVs=; b=VQhXfp/coHPX1f7SV0jCNZc3PQ/lwU+Do+zy6ZNtTlVWbrnW4mrJw4BTZlub8imJNd XGhoraTwEmz+cH5hqSPn2UPRaEVE3ede+dGQMPw4N+i1YP861TjDNB3KvV5vD6C0hYH9 3ZaM+akjA6io1damcdydaItv5FSqVtoMDRKyg2ifAkDPpNXOYXf5CZM8NuxPv9M6DLDF B2oA3uAY2ImrbiQW+wNK/Q10vKPTlGNDJobzpNorBRQAJEkTFLmdqtCFc2oYQujwYWGE C9wmQT3Hbsu+xjTVFVquEJdJX9EBQ2APfbawcPlLRwMxNNuiZNmJdfcrOBKpo5CkBkHd +dWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705594826; x=1706199626; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bgC7laYDhcy/d0aRJ1ysrFusf7tOC86i0x04lkEFoVs=; b=bJjcMHF7z5wDTSP8Z0E4Gfmoq3vErtsuC4EPqA4U5bPDXx4VL5r6HWuIIcCSW4yznV AsrjDpwMYuBGRWhatmhlvQmGlh4wIUoMmthug5wfUp5W9xdampJ7mq1Fwh1fvA81/eiA OyiSqQD5nb0XtzOhu4SAGD3RLN5m21CqCtj8f2tma0yXpi0/FO8eQ1IBua8tqQ1CL/Xw Mi+9g1a+4a6I3YxFiRlnUqr9IdUvubFeEeWAa+whXLu+RRUIB5VvVDjGwoGP8cAHFtOF GJMJp7YtziA8WLuQp5YgoNtbhrH7oSb9wlmH2RCkucQZ6/iL836+jDTU111wtp88KemY 7bcQ== X-Gm-Message-State: AOJu0YwYAac6eabuTtieHfc6l0QW/51FusqUOjRhnIYt8vNDCihzg6Ez HZ54wuKGvJbldVClVPfbwd8nVruhAZ6JMrvjVNUr/xM5sCDKvrJoRsDpjlFoob+ZuNtHcjigB5x yJlTI99ZKLed+bnQI/v6RFp2wFDOZsT+w X-Google-Smtp-Source: AGHT+IEqY6Uih98Rgb8thMBaYZdaZTy876G9mPGc7gexuDH4NDCQtGhosInFg7qrzyov0MN9HNKsdQAYUoluQRzLqNk= X-Received: by 2002:a2e:83c3:0:b0:2cc:5cd5:965f with SMTP id s3-20020a2e83c3000000b002cc5cd5965fmr595058ljh.8.1705594825949; Thu, 18 Jan 2024 08:20:25 -0800 (PST) MIME-Version: 1.0 References: <205735b2-11e1-4b5e-baa2-7418753f591f@eastlink.ca> <7b20b425-59b2-466d-a9aa-a2768d1d4633@app.fastmail.com> <4b475319-ef78-4d46-a62c-27c3b0af3ea4@eastlink.ca> <49702cd2-814c-4461-9819-cc2b85bd3ea2@eastlink.ca> In-Reply-To: From: "Mark J. Reed" Date: Thu, 18 Jan 2024 11:20:13 -0500 Message-ID: Subject: Re: Empty element elision and associative arrays (was Re: Slurping a file) To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000bb463b060f3abd43" X-Seq: 29513 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000bb463b060f3abd43 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 15, 2024 at 2:02=E2=80=AFAM Lawrence Vel=C3=A1zquez wrote: > There is no "inevitable" teration order; one must be usually be chosen an= d > implemented > explicitly, which is extra complexity that many languages choose not to > bother with. Indeed. To be clear, several do choose to bother; examples include Python since 3.6, Ruby since 1.9, and PHP, which all maintain their associative data types in insertion order. (That introduces potential pitfalls in PHP, where *all* arrays are associative; regular ones just have numeric keys, but those can still be rearranged out of numerical order! JavaScript avoids that pitfall by using numeric order for numeric keys while maintaining insertion order for non-numeric ones.) Closer to home, the KornShell keeps its associative arrays in lexical order by key. Which is to say there is precedent for keeping things in a specified order, but Zsh doesn't do so. Even if it were changed such that it started to do so as of 6.0 or whatever, you'd still have to write code to check the version and either fail ungracefully or fall back to maintaining the order in a separate array anyway. So even in that world, it's simpler to just do the separate ordering in the first place, yielding code that works in any version =E2=80=93 at least, any version with associa= tive arrays. --=20 Mark J. Reed --000000000000bb463b060f3abd43 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jan 15, 2024 at 2:02=E2=80=AFAM L= awrence Vel=C3=A1zquez <larryv@zsh.org= > wrote:
There is no "inevitable" teration orde= r; one must be usually be chosen and implemented
explicitly, which is extra complexity that many languages choose not to bot= her with.

Indeed. To be clear, several do c= hoose to bother; examples include Python since 3.6, Ruby since 1.9, and PHP= , which all maintain their associative data types in insertion order. (That= introduces potential pitfalls in PHP, where all arrays are associat= ive; regular ones just have numeric keys, but those can still be rearranged= out of numerical order! JavaScript avoids that pitfall by using numeric or= der for numeric keys while maintaining insertion order for non-numeric ones= .)

Closer to home, the KornShell keeps its associa= tive arrays in lexical order by key. Which is to say there is precedent for= keeping things in a specified order, but Zsh doesn't do so. Even if it= were changed such that it started to do so as of 6.0 or whatever, you'= d still have to write code to check the version and either fail ungracefull= y or fall back to maintaining the order in a separate array anyway. So even= in that world, it's simpler to just do the=C2=A0separate ordering in t= he first place, yielding code that works in any version =E2=80=93 at least,= any version with associative arrays.

--
Mark J. Reed <markjreed@gmail.com>
--000000000000bb463b060f3abd43--