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 15:21:57 +0300 Message-ID: <83czqun2fu.fsf@gnu.org> References: <83fsvqn49m.fsf@gnu.org> <70DB6978-5994-478A-8118-4A2EFE5FE379@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="30206"; 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 14:23:05 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 1mAtRo-0007b7-FB for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 14:23:04 +0200 Original-Received: from localhost ([::1]:55316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAtRm-0001Am-If for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 08:23:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAtQv-0000TJ-R7 for emacs-devel@gnu.org; Tue, 03 Aug 2021 08:22:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47998) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAtQt-0006ux-LS; Tue, 03 Aug 2021 08:22:07 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1249 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 1mAtQq-0003xk-O0; Tue, 03 Aug 2021 08:22:07 -0400 In-Reply-To: <70DB6978-5994-478A-8118-4A2EFE5FE379@gmail.com> (message from Fu Yuan on Tue, 3 Aug 2021 07:53:54 -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:271965 Archived-At: > From: Fu Yuan > Date: Tue, 3 Aug 2021 07:53:54 -0400 > Cc: stephen_leake@stephe-leake.org, cpitclaudel@gmail.com, > monnier@iro.umontreal.ca, emacs-devel@gnu.org > > Oh no, I don’t mean that. I meant that, for example, functions like node_start_byte, which returns the byte position of the beginning of the node, will now be node_start_pos, which returns a point position. That's called "character position". Let's use the accepted terminology, to minimize misunderstandings. So in what sense are character positions easier to use than byte positions? > And if I want the byte position of the beginning of the node, I can use (position-to-byte (tree-sitter-node-start-pos node)) Caveat: position-to-byte can be expensive. So in time-critical code, such as the display engine, we keep both character position and byte position, and update them in sync. Then you can use whichever is easier in each case.