From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: Re: equality of syntax objects Date: Mon, 20 May 2024 16:53:06 +0200 Message-ID: References: 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="36777"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon May 20 16:53:52 2024 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s94Od-0009Pn-Ea for guile-user@m.gmane-mx.org; Mon, 20 May 2024 16:53:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s94OB-0006Vt-AG; Mon, 20 May 2024 10:53:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s94OA-0006VX-7G for guile-user@gnu.org; Mon, 20 May 2024 10:53:22 -0400 Original-Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s94O7-0001vd-LV for guile-user@gnu.org; Mon, 20 May 2024 10:53:21 -0400 Original-Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3c9cc681ee0so1346459b6e.0 for ; Mon, 20 May 2024 07:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716216798; x=1716821598; darn=gnu.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=EDXd2rEcJ0OIF3O4Qb2K3P6fUvahBORLxu/itAUFEvo=; b=ZIsdl8ElXzc9Tgk4DG+GLY5dph5ib6mtRamaje76FSvrrV5Fpt+Y2XGxaGx+VKetcn VMYBDf6/nqAzJ95FvmN2hiUCcRgbOB9rN/kQeHO9tmkXtxDkTa3bftVUO8OoGd0TuaIa l4RPagWodZRE84aQO0fv3W9sGaIBAOc9hhQXr05611p8s+kEv3oT3tA8sWf4fpdhstly CyUNRVOl+eHVYMhxSfEFNPXwY3RhfMn1i0UQ1S55e0d8wzv9Sw5FYqacECBzIyDSB61n 7TSGdiUD+alREO7TaMXm/zHhNQ9rLGkkEsQSyuwke63naGYkhYSqz2LrPW5mYCXNxCqu KrGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716216798; x=1716821598; 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=EDXd2rEcJ0OIF3O4Qb2K3P6fUvahBORLxu/itAUFEvo=; b=uB+wwUuyn71kdPs+ZfFvDHj/rlfQjvP6C5rrLZe0bldYHafpRV24chBE3iH5rycKr9 OSAKIdnyco3jDHe1lso9obd37tIcu7rg8no1AiFgLuQUntUDa14DNx4NI8/brQjHIXvX EJw7c8TiqfC7qPPXFCDrYSka3/kp8q/TadVzNupakQ2WCbcUuPAlIsk12IHSFpXBqmUZ RBoolT66L8AexN3s4f4SRdgW5QeTeW6sUe+9j7zm3Ip9ht7SJUqKaL8cI6RuizsZNOe4 PbQbNj9zKH1A0tR3eYvmpD+Jip5zuvPJc/c8bkcPYee5A7MV6XwJ5wINwfydTEzy2Qh0 N0Dg== X-Gm-Message-State: AOJu0YxFxkUjz+tL7XYTD7tb84qiQnmvcGYQ9TvtFSMxGXe4SDepapW+ V96ak448mx4LOum0+Cpqyi5vC472dHAONlR9jaKZWhq9jan8WR2uxCtA+i3bJ3NJQjdmpsUZGij x1fos+nyNdOoJke/9OFT5Ben5f+VtOJcKGfg= X-Google-Smtp-Source: AGHT+IGD1XnudyG5VpLzCBbvstUD5F+oyKxQFXXLZlEYDGGR1mYGCBqyeKbzlzlXlRS9rhnGbgRUq8WRSGqmZOlNrpE= X-Received: by 2002:a05:6808:2012:b0:3c9:c3ca:e2cb with SMTP id 5614622812f47-3c9c3cae324mr15365920b6e.11.1716216798077; Mon, 20 May 2024 07:53:18 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=damien.mattei@gmail.com; helo=mail-oi1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19662 Archived-At: asked more simply: how to know ,for two syntax objects now different but that represents two different procedures created with the same name at two different moment,how to know that the names are still the same? i see two solutions: -parse the representation string to know for example expt that expt is in both string: "#" "#" not really pretty but will work.I test it in Racket and kawa too... -keep an up to date value of #'expt to use it for compare to avoid falling on an old #'expt that match an old procedure ,i'm not sure it is clear but i already do it last year for the same problem when parsing not syntax but sexpr composed of real procedures (that were changing in time due to overloading) or quoted ones (which is the worse because you have to re-evaluate later and it again depends of context....and that not reliable, but quoting (with syntax) is the only solution to manipulate 'and' / 'or'. So i think the best solution is the simple and not pretty that rely on parsing the string representation. On Mon, May 20, 2024 at 1:42=E2=80=AFPM Damien Mattei wrote: > hello, > > i want to check the equality of two syntax objects. > > i wrote this macro: > > (define (check-syntax=3D? obj1 obj2) > (display "check-syntax=3D? : obj1 =3D") (display obj1) (newline) > (display "check-syntax=3D? : obj2 =3D") (display obj2) (newline) > (define rv > (and (identifier? obj1) ;(syntax? obj1) > (identifier? obj2) ;(syntax? obj2) > (free-identifier=3D? obj1 obj2))) > (display "check-syntax=3D? : rv =3D") (display rv) (newline)(newline) > rv) > > What works: > > if i have expt (exponentiation) , the same procedure used and checked fro= m > to different files, i have this output in debug when doing some processin= g, > note i think it is important to focus on the filenames of the syntax > object also: > > when computing {1 + 2 expt 3} > gives right result: > 9 > > note that this computation requires operator precedence analysis doing on > the syntax by the process... > > debug output include: > > check-syntax=3D? : obj1 =3D# > check-syntax=3D? : obj2 =3D# > check-syntax=3D? : rv =3D#t > > now i change expt by overloading itself by one of my macro: > > (overload-existing-operator expt expt (number? number?)) > > i will not explain what is the overloading algorithm here and why i > overload expt.(in summary to allow n-arity with exponential such as {2 **= 3 > ** 4} or {2 expt 3 expt 4} > But note that expt is still working,even in infix guile mode: > scheme@(guile-user)> {2 expt 3} > $2 =3D 8 > and is now an n-arity operator: > scheme@(guile-user)> {2 expt 3 expt 4} > $6 =3D 2417851639229258349412352 > scheme@(guile-user)> (expt 2 3 4) > $7 =3D 2417851639229258349412352 > (and with evaluation from right to left as by convention for expt ,which > is different for operator such as + or - or * and / that are evaluated fr= om > left to right) > but that is of little importance with the current problem. > > expt looks now like that: > scheme@(guile-user)> expt > $3 =3D # > new-funct is an inner function created by overloading process. > > and : > scheme@(guile-user)> #'expt > $4 =3D # > > syntax looks like the original expt , no problem with that. > > now the ouput in debug,after overloading expt: > > on the calculus: > {1 + 2 expt 3} > note that this computation again requires operator precedence analysis > doing on the syntax by the process... > > check-syntax=3D? : obj1 =3D# > check-syntax=3D? : obj2 =3D# > check-syntax=3D? : rv =3D#f > > > and the result 3 is wrong .(calculus has been truncated to first value 3 > at rightmost as computation with expt goes from right to left but that is > of no concern with the problem again) > > What i understand is even if obj1 and obj2 display the same in the output > debug,the expt definition has changed and the checking is not only about > litteral syntax but also with an hidden environment or context. > > That seems normal about syntax in all scheme. > > But i want ,for this point , only to manipulate "mathematic" syntax here. > > I have a few simple or complex idea for solution , some not really pretty > and i ask opinion for solving this problem? > > just what i need is a way to find equal the expt even if it has been > modified, only from a litteral point of view here. > > regards, > > damien > > > > > >