From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Tue, 03 Aug 2021 16:03:27 +0300 Message-ID: <838s1in0io.fsf@gnu.org> References: <83czqun2fu.fsf@gnu.org> <8D678FFA-51BB-4835-B14B-8A22C575666A@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34226"; 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: Fu Yuan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 03 15:04:31 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 1mAu5v-0008fd-CA for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 15:04:31 +0200 Original-Received: from localhost ([::1]:59558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAu5t-0000FU-F5 for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 09:04:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAu52-0007Qg-Cs for emacs-devel@gnu.org; Tue, 03 Aug 2021 09:03:36 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48842) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAu51-0002wa-N5; Tue, 03 Aug 2021 09:03:35 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3810 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAu51-0003fE-9T; Tue, 03 Aug 2021 09:03:35 -0400 In-Reply-To: <8D678FFA-51BB-4835-B14B-8A22C575666A@gmail.com> (message from Fu Yuan on Tue, 3 Aug 2021 08:50:45 -0400) 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:271973 Archived-At: > 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 > > > So in what sense are character positions easier to use than byte > > positions? > > Here are what you can do with positions: > > - find the smallest node that encloses a range (BEG . END) > - get the beginning and end of a node > > Since all other functions use character position (eg, put-text-property, point), using character positions saves lisp code some ‘position-to-bytes’. 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. > Internally, tree_sitter.c will continue to use byte positions, of course. "Internally", as opposed to what? And what is "internal" in this context? I thought we were talking only about the internals.