From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fu Yuan Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Tue, 3 Aug 2021 09:08:04 -0400 Message-ID: References: <838s1in0io.fsf@gnu.org> Mime-Version: 1.0 (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="16500"; mail-complaints-to="usenet@ciao.gmane.io" Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 03 15:08:57 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mAuAD-00046g-6v for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 15:08:57 +0200 Original-Received: from localhost ([::1]:39104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAuAC-0005cC-4x for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 09:08:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAu9S-0004jl-Hc for emacs-devel@gnu.org; Tue, 03 Aug 2021 09:08:10 -0400 Original-Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]:38501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAu9P-00060n-Tc; Tue, 03 Aug 2021 09:08:10 -0400 Original-Received: by mail-qv1-xf2d.google.com with SMTP id cg4so5485684qvb.5; Tue, 03 Aug 2021 06:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=2Hvo04VTTYCvVIo4j0DZWA4rAd04VuQtTIwCBmbw5ow=; b=ZY46iyniQQMx/h2XNA5ghepboaJOdSh0D9EDUJN60sfrR5CoCqrNOX19gne3XoAz2u n8ZDLjb+GibNEV2LvS6XoRE9lgOnYxa/sQaFWqsJIUwLyRtEdhhYDYvsB9JWHsnGoEY6 9Itat/Svdpu+3I4ZxpJ5ANtkNcr8l/CcoogHsp1UG3DNoWaeUIrSNqrMWFEvyksgSlKV Vr3MX03GvMDSjGSTwTDxttnqaX/WyK2hCuuNf3heFF4VHYsetXor0IE2jA4+AYMqDcV4 qAvAqOPVJrjr7FM9mIQt4rPYWD3MIg7FQ+j2GZGbi/FO2iX9vRCQgFSu2QAcsJaPoTCJ Gu0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=2Hvo04VTTYCvVIo4j0DZWA4rAd04VuQtTIwCBmbw5ow=; b=M5fLCxXRfidLcfsun4+yxwty7KdPqHpKBphITHF3JDmxP7CzDcZS7Ja4ktjfsNAOiV T1tPNX4EngALJjkDg2vn5TeFODZCjmfNsL363AKNAv1oNR6ccXPqSMiwtOvzSd2LyDQ/ Cq+usfq4U/4dNcBWcGUSyDjB7LpnTvMJEhyIvFTpiNR7IRXPzoTEnyZY05d1MZNkggf1 y3QJaYMnv1Wc/3uX64oY9E9pYw84x3GECovYtoNG6YHu35irX/armvasre3YM3dttZ1J tVQs+A4JEbMkBOcdPPgnCSuh3RsqiL2Cnz2R1HPblU/NFni9QfbjtYsMZnscEgqOWJ+e lMIA== X-Gm-Message-State: AOAM531mgvPe5B8vVofSrBlO1dgHEbx0KuNI8JXGhx+QFg+RhHMq24AO yO8Hzs/DlMyTIst1fogEpWE= X-Google-Smtp-Source: ABdhPJyWxczKfHjTL1PhDFApdq0F3QP9uJ3ufO4N/J2/P8DbFxEu1MI6MS1vxW2QpTM3WsJ5oHKB7Q== X-Received: by 2002:a05:6214:a63:: with SMTP id ef3mr21331316qvb.15.1627996086523; Tue, 03 Aug 2021 06:08:06 -0700 (PDT) Original-Received: from ?IPv6:2607:fb90:a902:79bf:ece0:4f2a:436e:c17b? ([2607:fb90:a902:79bf:ece0:4f2a:436e:c17b]) by smtp.gmail.com with ESMTPSA id d19sm7432179qkn.94.2021.08.03.06.08.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Aug 2021 06:08:06 -0700 (PDT) In-Reply-To: <838s1in0io.fsf@gnu.org> X-Mailer: iPhone Mail (17H35) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=casouri@gmail.com; helo=mail-qv1-xf2d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271976 Archived-At: > =E5=9C=A8 2021=E5=B9=B48=E6=9C=883=E6=97=A5=EF=BC=8C=E4=B8=8A=E5=8D=889:03= =EF=BC=8CEli Zaretskii =E5=86=99=E9=81=93=EF=BC=9A >=20 > =EF=BB=BF >>=20 >> From: Fu Yuan >> Date: Tue, 3 Aug 2021 08:50:45 -0400 >> Cc: stephen_leake@stephe-leake.org, cpitclaudel@gmail.com, >> monnier@iro.umontreal.ca, emacs-devel@gnu.org >>=20 >>> So in what sense are character positions easier to use than byte >>> positions? >>=20 >> Here are what you can do with positions: >>=20 >> - find the smallest node that encloses a range (BEG . END) >> - get the beginning and end of a node >>=20 >> Since all other functions use character position (eg, put-text-property, p= oint), using character positions saves lisp code some =E2=80=98position-to-b= ytes=E2=80=99.=20 >=20 > If you are talking about Lisp, then yes, character positions are a > much better interface. But on the C level, sometimes you need byte > positions, sometimes character positions, and sometimes both. Since > you didn't say what level was this about, I cannot say something more > intelligent. >=20 >> Internally, tree_sitter.c will continue to use byte positions, of course.= >=20 > "Internally", as opposed to what? And what is "internal" in this > context? I thought we were talking only about the internals. By internally I mean C level. I will change lisp interface functions to acce= pt and return character positions, and C level code will keep using byte pos= itions. I=E2=80=99ll try to make myself clearer next time :-) Yuan=