From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OKHcDeGKH18iFwAA0tVLHw (envelope-from ) for ; Tue, 28 Jul 2020 02:18:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SO7ECeGKH1+AWQAA1q6Kng (envelope-from ) for ; Tue, 28 Jul 2020 02:18:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A20EA9403A9 for ; Tue, 28 Jul 2020 02:18:08 +0000 (UTC) Received: from localhost ([::1]:52448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0FBv-0003HV-LL for larch@yhetil.org; Mon, 27 Jul 2020 22:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0FBq-0003HK-2j for guix-patches@gnu.org; Mon, 27 Jul 2020 22:18:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k0FBp-0001GW-Q9 for guix-patches@gnu.org; Mon, 27 Jul 2020 22:18:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k0FBp-0002QI-Mn for guix-patches@gnu.org; Mon, 27 Jul 2020 22:18:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42456] [PATCH] gnu: Rename python-hy to hy. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Jul 2020 02:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42456 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Jesse Gibbons Cc: 42456@debbugs.gnu.org, Brett Gilio Received: via spool by 42456-submit@debbugs.gnu.org id=B42456.15959026369256 (code B ref 42456); Tue, 28 Jul 2020 02:18:01 +0000 Received: (at 42456) by debbugs.gnu.org; 28 Jul 2020 02:17:16 +0000 Received: from localhost ([127.0.0.1]:56243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k0FB5-0002PE-UL for submit@debbugs.gnu.org; Mon, 27 Jul 2020 22:17:16 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38763) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k0FB3-0002P0-Px for 42456@debbugs.gnu.org; Mon, 27 Jul 2020 22:17:14 -0400 Received: by mail-wr1-f67.google.com with SMTP id a14so16718328wra.5 for <42456@debbugs.gnu.org>; Mon, 27 Jul 2020 19:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=jaixjY3WDzN8jW/8+RhtgMTtmawEhOhbwK3i7OoxBOA=; b=MRQXYdggl4/JvLWN2W4rcphlJC33Bx0OWnvc2dt+gzOhqsdJpwsBfep73/Jkv85d82 Y0CgHs8OZ1i0rGnOdLCQRfbuRGrfS3mGB0RB9l1GILo8GzoWuGUejTmnXjSsdp1/sj0t ODFeXeftaI2I+zfx4EC4T8RNXf7S581cBLJHh0bZGzf0uHqnPz8loAV93qWaZaMbhoLr orqXA3YI69TnXxoBwcPHE+bc4Vdi3Utn1x35eyfsEPK3Zc/wiMpPQabhsES8gUIBXUGg CjGEz+B+pO+Uhw9meKczxK/vL1zb4sWmV7i1uct2lzrjHOSaGuC5T5+pahMGhZN+wj1w zyRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=jaixjY3WDzN8jW/8+RhtgMTtmawEhOhbwK3i7OoxBOA=; b=XMN84EyFk/dm26qe8E0bFjJXRHhtF/OZ7J+3P2T9FNN8NI2WzVVV6nEivbLgaRF+K6 Uhfcr2BA19tNyvLaoavoc5fAGzv6RD1h22d2S3mSN24srFjaejNmzPtUNqLU8k6/YssE OCsDvfMQE0+zDOayPrTuvc/sjMYcn7oudxI0M0HVqnZOfd0ZdI4nqqqP5QF9pnB5WG24 LnducRldRCljJfcj6iPymMqo/EnFqIIrNn/KVJaYD0ucQ2KN/P6ZqsxGBAxWPF1XeM6y 8PvqHYkrLAupq6pxQ7CcPBoXJOWfV2GDnO3yep7/LymLjpbXqKpiDTgB8x6ns+oJ3eI4 5llQ== X-Gm-Message-State: AOAM533ry2qXeTAKM01UUrF4IT+5+nz3aSy1A8ekAT/or0QicBzrRWnU P8JlMSCoJybmqvRrbhpeYRpXoFUw X-Google-Smtp-Source: ABdhPJwnnRZTQ9AJsKSLxnk1Et8/Ms3UyH5QSv6mkWmQe05Jlp1VZsop39gtNjxLW/fmz+rgVCjtwA== X-Received: by 2002:a5d:6641:: with SMTP id f1mr22684111wrw.307.1595902627510; Mon, 27 Jul 2020 19:17:07 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id z127sm1829035wme.44.2020.07.27.19.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 19:17:06 -0700 (PDT) From: zimoun In-Reply-To: References: <1dc02d59-c67b-2002-6a99-ceb0cdc24645@gmail.com> <87a6zo5rdq.fsf@gnu.org> <08f72489-fb0b-c367-ff9e-6cb3beb4e127@gmail.com> Date: Tue, 28 Jul 2020 04:17:05 +0200 Message-ID: <86k0yoz8m6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=MRQXYdgg; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: M7xBzyp3cw83 Dear, On Mon, 27 Jul 2020 at 17:05, Jesse Gibbons wrote: > What about Hy macros? According to > https://docs.hylang.org/en/stable/language/api.html#require they make no > changes to the program when imported with require. If I write a Hy > library with nothing but useful macros, will python be able to use that? Macros will be represented as HyExpression or something like that (I have not checked now and I have not played with Hy since 2014 :-)). Say an HyObject which then needs to be =E2=80=9Ccompiled=E2=80=9D into a Python= AST, then the Python AST is =E2=80=9Ccompiled=E2=80=9D to bytecode. https://docs.hylang.org/en/master/language/internals.html Or simply said: What if you want to use a macro that=E2=80=99s defined in a diff= erent module? import won=E2=80=99t help, because it merely translates = to a Python import statement that=E2=80=99s executed at run-time, and m= acros are expanded at compile-time, that is, during the translation from Hy to Python. Instead, use require, which imports the module and makes macros available at compile-time. require uses the same syntax as import. https://docs.hylang.org/en/master/tutorial.html#macros --8<---------------cut here---------------start------------->8--- $ hy --spy =3D> (defmacro do-while [condition &rest body] `(do ~body (while ~condition ~body))) from hy import HyExpression, HySymbol import hy hy.macros.macro('do-while')(lambda hyx_XampersandXname, condition, *body: HyExpression([] + [HySymbol('do')] + [body] + [HyExpression([] + [ HySymbol('while')] + [condition] + [body])])) --8<---------------cut here---------------end--------------->8--- Does it make sense? > When I call Hy2py on a Hy file with nothing but the sample macro at > https://docs.hylang.org/en/stable/language/api.html#defmacro it gives an > error. Is this expected, or is this a guix-related bug? If this is > expected, then I think Hy macros are significantly more useful to Hy > than to python without the ast library, and if you want to use Hy macros > for parts of a python app you might as well use Hy. Python and Hy are not one-to-one. Hy also removes Python=E2=80=99s restrictions on mixing expression= s and statements, allowing for more direct and functional code. [=E2=80= =A6] https://docs.hylang.org/en/master/whyhy.html So your problem hy2py seems expected. The macro is represented by a Hy AST which cannot be compiled to Python AST. However, note that =E2=80=9Chy2py=E2=80=9D is not bullet-proof because goin= g from AST to Python code is not straightforward. --8<---------------cut here---------------start------------->8--- $ echo "(defn f [n] (+ n 1))" | hy2py --with-ast - Module( body=3D[ FunctionDef(name=3D'f', args=3Darguments(posonlyargs=3D[], args=3D[arg(arg=3D'n', annotation=3DNone)], vararg=3DNone, kwonlyargs=3D[], kw_defaults=3D[], kwarg=3DNone, defaults=3D[]), body=3D[Return(value=3DBinOp(left=3DName(id=3D'n'), op=3DAdd, r= ight=3DConstant(value=3D1)))], decorator_list=3D[], returns=3DNone) Traceback (most recent call last): File "/gnu/store/b2cyhq822sywidaqnpg6kminvr34z9rq-python-hy-0.18.0/bin/.h= y2py-real", line 12, in sys.exit(hy2py_main()) [...] File "/gnu/store/i7bq751zql0vw1mb3x20k7fla9ilszwh-python-astor-0.7.1/lib/p= ython3.8/site-packages/astor/op_util.py", line 102, in get_op_precedence return precedence_data[type(obj)] KeyError: --8<---------------cut here---------------end--------------->8--- Well, it could also be a bug=E2=80=A6 :-) >> I do not think it makes sense having 'hy-build-system' because Hy uses >> all the Python machinery, not to say Hy is simply Python with >> parenthensis. ;-) > As I mentioned, hy-build-system would just make things a little more > convenient. Programs written even partially in Hy will require the Hy > package, but I wouldn't bother hacking a new build system together > unless there are other things required for all Hy packages. Do such > things exist? If not, I will let it go. >From my point of point, Hy packages are just Python packages. For instance, the 2 Hy libraries you mentioned are regular PyPI package, installable with =E2=80=9Cpip=E2=80=9D. Well, python-hy would be an implic= it dependency but AFAIK that=E2=80=99s all. > Similar things can be said of Clojure. Clojure is compiled into Java > bytecode, then run on the Java VM. Java programs can run Clojure code, > and vice versa. And just like Clojure and Java, Hy and Python have very > different grammar and are therefore not the same language. Yet Clojure > is not packaged as java-clojure. I do not know well Clojure neither the Java ecosystem. But I think the distribution of Clojure packages is a bit different than the distribution of some other Java packages. The tools used to build are not necessary the sames. Which is not the case for Hy: it uses =E2=80=9Cpi= p=E2=80=9D and/or the Python setuptools =E2=80=93 it could have changed since I am not following Hy very closely. > Though inconsistencies in naming conventions tend to bother me, I > personally am indifferent about what Hy is named. As the saying goes, "A > cactus by any other name would pop all the balloons you throw at it that > don't completely miss it." (Or something like that.) I only submitted > the patch because I had renamed python-hy to hy in my personal channel a > while ago, and the people on the IRC suggested I should send the change > as a patch when I mentioned it there recently. So if my patch is > accepted is up to those who are more familiar with Hy and Guix than I > am. I think the only time it will matter to me is if I am the first to > submit a package that requires Hy, since such a package will be written > for my channel and my channel won't be adjusted by then to build a > package dependent on hy. About the name, I am indifferent too. :-) Well, it could be nice to split the big Python files. ;-) All the best, simon ps: Note that I said =E2=80=9CHy code compiles to Python (and vice versa :-))= =E2=80=9D which is inaccurate; especially about the =E2=80=9Cvice versa=E2=80=9D. ;-)