all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: phst@google.com, emacs-devel@gnu.org
Subject: Re: [PATCH] Allow inserting non-BMP characters
Date: Tue, 26 Dec 2017 22:22:36 +0200	[thread overview]
Message-ID: <83zi65grxv.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkRdDWHv2uiB4nmrXAv6L9a76iimCde+dYrb1LwQnwh76Q@mail.gmail.com> (message from Philipp Stephani on Tue, 26 Dec 2017 18:50:46 +0000)

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Tue, 26 Dec 2017 18:50:46 +0000
> Cc: emacs-devel@gnu.org, phst@google.com
> 
>  I don't think we have a policy to prefer inline functions to macros,
>  and I don't think we should have such a policy.  We use inline
>  functions when that's necessary, but we don't in general prefer them.
>  They have their own problems, see the comments in lisp.h for some of
>  that.
> 
> Thanks, the only discussion I saw there was about some performance issues:

Let me make it more clear:

Macros are faster in non-optimized builds (that's why we have such a
complex setup with them in lisp.h).

Macros are also better for debugging, especially when you debug a core
file.  Invoking a function when debugging needs a running process, so
it cannot be done when debugging a core file.  And sometimes the
compiler doesn't keep a non-inlined version of an inline function, so
it cannot be called from the debugger at all.

On the downside, macros can be less readable when they are complex,
and have additional problems when you need local variables.  (None of
that is relevant to the issue at hand.)

>  > and don't seem to be correct either (what about a value such as 0x11DC00?).
> 
>  ??? They care correct for UTF-16 sequences, which are 16-bit numbers.
>  If you need to augment them by testing the high-order bits to be zero
>  in your case, that's okay, but I don't see any need for introducing
>  similar but different functionality.
> 
> I'd be OK with using the macros since they already exist, but I wouldn't want to touch them without converting
> them to functions first, and for using them in nsterm.m I'd have to move them around.

You don't need to convert the macros to anything, just add a test that
you need, as in

   if (c < 0xFFFF && UTF_16_HIGH_SURROGATE_P (c))
     ...

>  > No new macros please if we can avoid it. Functions are strictly better.
> 
>  Sorry, I disagree.  Each has its advantages, and on balance I find
>  macros to be slightly better, certainly not worse.  There's no need to
>  avoid them in C.
> 
> I disagree, see e.g. https://gcc.gnu.org/onlinedocs/cpp/Macro-Pitfalls.html and many other sources.
> Sometimes macros are unavoidable, but not here.

See above.

>  Yes, but why do you first copy the input into a separate buffer?  Why
>  not convert each UTF-16 sequence separately, as you go through the
>  loop?
> 
> Message (method) invocations in Objective-C have high overhead because they are late-bound. Therefore it is
> advisable to minimize the number of messages sent.
> https://developer.apple.com/documentation/foundation/nsstring/1408720-getcharacters?language=objc also
> indicates that a (properly implemented) getCharacters call is faster than calling characterAtIndex in a loop.

Is that a fact, or should we measure that?



  reply	other threads:[~2017-12-26 20:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-24 16:00 bug#29837: UTF-16 char display problems and the macOS "character palette" Alan Third
2017-12-24 16:56 ` Eli Zaretskii
2017-12-24 18:23   ` Alan Third
2017-12-24 18:57     ` Eli Zaretskii
2017-12-24 19:28       ` Alan Third
2017-12-24 19:34         ` Eli Zaretskii
2017-12-25 20:13           ` Philipp Stephani
2017-12-25 21:01             ` [PATCH] Allow inserting non-BMP characters Philipp Stephani
2017-12-26  1:26               ` Alan Third
2017-12-26  4:46               ` Eli Zaretskii
2017-12-26 10:35                 ` Philipp Stephani
2017-12-26 16:11                   ` Eli Zaretskii
2017-12-26 18:50                     ` Philipp Stephani
2017-12-26 20:22                       ` Eli Zaretskii [this message]
2017-12-26 21:36                         ` Alan Third
2017-12-27  3:41                           ` Eli Zaretskii
2017-12-28 11:38                             ` Alan Third
2017-12-28 12:31                               ` Philipp Stephani
2017-12-28 16:29                                 ` Eli Zaretskii
2017-12-29 20:14                                   ` Philipp Stephani
2017-12-29 20:27                                     ` Eli Zaretskii
2018-01-07 15:51                                       ` Philipp Stephani
2018-01-07 17:40                                         ` Eli Zaretskii
2018-01-07 18:44                                           ` Philipp Stephani
2017-12-25 21:07             ` bug#29837: UTF-16 char display problems and the macOS "character palette" Philipp Stephani
2017-12-26  1:34             ` Alan Third

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83zi65grxv.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=phst@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.