From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30725 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bastien DUMONT Newsgroups: gmane.text.pandoc Subject: Walk and deep copy in Lua filters Date: Sun, 12 Jun 2022 11:16:59 +0000 Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38224"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDCINCES2QJRBUEWS6KQMGQE4QVZGKY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Jun 12 13:17:40 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f63.google.com ([209.85.128.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o0Lb9-0009k3-Gg for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 12 Jun 2022 13:17:39 +0200 Original-Received: by mail-wm1-f63.google.com with SMTP id p42-20020a05600c1daa00b0039c62488f7esf4177470wms.7 for ; Sun, 12 Jun 2022 04:17:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655032659; cv=pass; d=google.com; s=arc-20160816; b=C0qSHdxamml4gf/qhVXBvxCpUvHjnF2PJ5y/yWF12XBbSs1lhqt67uJENfOD+MzD4K K4LdMftn3NFWLXvHlzyYKOvD8JdI+P+h71qckmMD/4ag8pWaZnIh3t3vQS6DPC9iju08 VeKXJ4dQqWhOO+zkTeLxd3gN3KRk8tBExNv1RTt8znFKlau0kYF/blfMnTXrxSZtryWo amwG1yy3I1GiD65BrDaNRLKnMNUaaY+zQlX3pSmyv70t1m89nmJP6NkQgOTsWUxDxhUs A6CAq/gswXX8vkw1k1kcie6SlFZFn8INh3Yp8kXtYsS4Khmo4xVJLhcu1z3yf86xqYXh 0v1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:to:from:date :sender:dkim-signature; bh=NcWYvGrv/U+v9kkqnCZX37msCFvsLWE2XwlmN88s/jA=; b=gnxK9y79T0OzVcbDvduvcS8HTEno17qxA1aNNSsi46EjCGL15+wf+UyjTW/QLcbYl5 9zfO+Goupd+o8/CPGQz0M9JvFX5II6EkRVgGnKtaNbAVGHiQkN5m09n3sMRnLnyrr4bc ktQt2JCi3kuef9vy7aeEdz7+iwCXMvxzKr1FctpwFvPmvsdZd9MOTn3xhmt4qFsqU74/ xIbeDWqXMBqVgk0AyYC+RpsNZ0lBuq/fIwjgkddy2byyX8bgG9pSakk53xGgZs2PKbCd kFZkgUOd521ne+B9vBAU1bLq2yb8nZ17rwEYheT/dt+cRxqSGZ7SOVVahFcmeHSh5f1Z Z1iw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=mVo4Kyp3; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=NcWYvGrv/U+v9kkqnCZX37msCFvsLWE2XwlmN88s/jA=; b=YiYHbWoS7SIwsTTzTvz7BMQzhIOa9tbR9205eAE2g1Myp9u3KEy0e7sjn3JlP9SU9D GkTQlT17t4plBGDxcjacPwhx5QVHldAN6PfV3eYhHfYDTc1ZKqLOSZjojA6ujPOGdNXP cYv2r0tYauAuaIUVdF6peYVi/5JX2ubMiigs9GWjUqbn5pwdc11kTYcu8h2M/i+skZpm PDwI4ppom/nLxrOU1ipyOisia/X9FcSBIgk7ukcJCNGzUe79SlHhiy52kTnUGn3PIS8K 4ok+FuFB7iilCpJdCuUsU0rRAh58dxkBCefKdLoniUFqa5EUzro+xOXtiF3eGY9l966C 5+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition:content-transfer-encoding :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=NcWYvGrv/U+v9kkqnCZX37msCFvsLWE2XwlmN88s/jA=; b=7scSfT6NUtK9MossMYutgKL/1EY3qV5YlzwwIcjbTwmI9i4R+AK+LmnukWgeWnySgL ZqR9sD9kwMFpKtnl60+XkTpDv1zHiRTC6k+FPeM94v5YLIwlHsS3Akf7MXVYfF6/tlQ+ Z9bRz/avACbw6NJuBF3GIDo6zSAwThhJucs4pTWR7GbGL08wGfjd7AWBc0//UPI7iPLg 6Ti1ppfMH9bdSHp2LN/lHkwwbClP1/tJ+yaOsNPvjQ0h2DLcd+oc/hXgphruzefUfny5 9eTWcwEApURCLrnocAMzA59rNPnNWv8vMTgWpUbjjp22AT5iaztFuKpzHDenzWQkGIcM Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532h5tpEz6k+4F65f7PdtbMhSggIqlRz+mwkf5WV6UmgNSV+B4Rr 8q2PCHQ0TLjG5fs8zQds0xY= X-Google-Smtp-Source: ABdhPJw51c+tJ2vxh7RNHIBkazmeyFwycnyN2LW4+jrD3TctQKgIDUeoyNljd0T1CK6j4yZGuYoXAA== X-Received: by 2002:a5d:47cc:0:b0:20f:e246:d7d with SMTP id o12-20020a5d47cc000000b0020fe2460d7dmr54638518wrc.2.1655032659072; Sun, 12 Jun 2022 04:17:39 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6000:1887:b0:218:5c3b:1a23 with SMTP id a7-20020a056000188700b002185c3b1a23ls1916794wri.0.gmail; Sun, 12 Jun 2022 04:17:35 -0700 (PDT) X-Received: by 2002:a05:6000:a0b:b0:219:f87e:86b with SMTP id co11-20020a0560000a0b00b00219f87e086bmr5267771wrb.570.1655032655269; Sun, 12 Jun 2022 04:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655032655; cv=none; d=google.com; s=arc-20160816; b=vIvSLJMO7agVWbG91b4ynrkV4Omyl5tKTPcUu6z1q5JLtiETIQmBjvK/tBF9VxKgvU V2efNDPOxKLm3f7M7tAj6/PBNph0MRb80KVYD5x2RYNAW3E2g+XnHa0DUzRoy6uhr5SA Qeldl8zZ8KVoqcINw/GlF9BP6T/DXxy3Z4GejClPireIhzcRum9CvtbGGtBkrDXK11HB ElA4mwsNVtJfxekRgPs/96cwME7CNChCFtMqwVN+QhJTBJnXno+91D4dSxpCxPyYlVSp ksHv9DR8/b5p63v0lfPtMHK12R5JUa62IiicklRX0kGTDGulz4omstPEcBT/KgWlFk54 WnCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-disposition:mime-version :message-id:subject:to:from:date:dkim-signature; bh=kA0ScPiOe1qtR51fcyDI6aEBWynthKAsIgCafGyXwfo=; b=hd1MKTq0l8JUKS9qxDCUAOxjSBbpS3VVNZDPi26WAe3dTngxkhW3jiuVoDcNmHvWWy 3NSsp/gRqStVay/LaXISGJepFevd3sWQoXi/RRPoyUSARc3svwiLlzx0OndWey1tEJD4 Du81zZETaVTnRRK2mE9mRm+hD8tGNtWOLIR/QiTbNHB59tM8j0VA866omSMYcZnkhoix tER1IfzQuilGHTIrCHEHHiDrcpIZz+dlZBkjS/AXImdmn94NiNAlKZGKhELPRZQ24qya 0dgwoQdfLS2+38YA26HWj3Bjtxg1OQ0HDNvXhqfMN6lK8IiVhEgzZPlrr5TjVVniDc9S Si9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=mVo4Kyp3; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Original-Received: from mout02.posteo.de (mout02.posteo.de. [185.67.36.66]) by gmr-mx.google.com with ESMTPS id p17-20020a5d4591000000b00219adf145aesi144787wrq.6.2022.06.12.04.17.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 04:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) client-ip=185.67.36.66; Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E06A6240107 for ; Sun, 12 Jun 2022 13:17:34 +0200 (CEST) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LLXH23Yg8z6tmR for ; Sun, 12 Jun 2022 13:17:34 +0200 (CEST) Content-Disposition: inline X-Original-Sender: bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=mVo4Kyp3; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:30725 Archived-At: Hi all, I just discovered by chance that the method walk returns a deep copy of the= passed object, leaving the original object untouched. See the following te= st case: ```deep-copy.lua local orig =3D pandoc.Emph({ pandoc.Str('one'), pandoc.Space(), pandoc.Str(= 'two') }) local copy =3D orig:walk({}) table.insert(copy.content, pandoc.Space()) table.insert(copy.content, pandoc.Str('three')) assert(#orig.content =3D=3D 3) assert(#copy.content =3D=3D 5) ``` `pandoc -L deep-copy.lua <<< ''` should return nothing (i.e. no error). However, in the documentation, it is only stated that the =E2=80=9CResult= =E2=80=9D is the =E2=80=9Cfiltered block/inline element=E2=80=9D: from this= indication alone, it seems not obvious to me whether the passed object is = changed (as it is customary with functions operating on Lua tables or userd= ata) or the method returns a new object. To be clear, I am very happy with the current behaviour, for it gives a ver= y simple means to get several deep copies of an objet and to manipulate the= m separately without having to regenerate the original object (e.g. via rat= her expensive calls to `pandoc.read()`). Nevertheless, since it is not real= ly documented, can it be considered to be deliberate and stable? If this is= the case, could it be possible to make explicit in the documentation, unde= r the header =E2=80=9CResult=E2=80=9D, that the original block or inline el= ement is left unchanged? --=20 You received this message because you are subscribed to the Google Groups "= pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/YqXK0Gyv%2B18RwQd1%40localhost.