ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Henri Menke <henrimenke@gmail.com>
Subject: Re: The odd semantics of \begincsname
Date: Sat, 17 Aug 2019 10:48:18 +0200	[thread overview]
Message-ID: <c4f2f5b5-594b-c06d-fe15-9ff3f208f49f@xs4all.nl> (raw)
In-Reply-To: <3c6496fd-2dc7-4bd9-1c72-74eaa5b7ae02@gmail.com>

On 8/17/2019 9:19 AM, Henri Menke wrote:
> Dear list,
> 
> According to the LuaTeX documentation:
> 
>      “The \begincsname primitive is like \csname but doesn’t create a
>      relaxed equivalent when there is no such name.”
> 
> I thought it would be possible to use this fact to skip the \relax-ed
> definition when \def-ining a new control sequence, but the following MWE
> fails with \inaccessible:
> 
>      \expandafter\gdef\csname yes\endcsname{}
>      \expandafter\gdef\begincsname no\endcsname{}
>      \bye
> 
> Is this a bug or is this behaviour intended?  Could this be fixed by
> making manufacture_csname aware whether it is in a def_cmd context or
> not?
[sorry to those who are not interested in these low level issues, just skip]

intended ... it expands to basically nothing so you get no token 
representing a 'name' after the gdef .. the expansion is pushed in from 
of whatever comes next (which could be another \expandafter for instance)

you suggest that if \begincsname could behave differently when it's 
after a \def, \gdef, (and then quite some more definition related 
commands), it could behave differently but it not an option

for instance (as mentioned) there can be more than one expansion going 
on after these define commands, like expanding a macro that itself 
expands to \csname so one has several \expandafters before the gdef 
then); there is actually no looking back in scanning tokens unless a 
token has been scanned already and looking forward would involve 
expansion so a circular mess

an option could be not to push something on the save stack (a side 
effect of creating the csname, which has a little impact on performance 
and nesting) but removing that bit might give other side effects (e.g. 
for successive reassignments inside a group, maybe even mixed local and 
global); i did a quick test with that and it gives quite incompatible 
output in ConTeXt so that's definitely a no-go (adding all kind fo 
saveguards and checks in the engine doesn't pay off, especially not for 
something that never was a problem)

some time ago i considered a convenience command \[e]defcsname, as it 
saves a few tokens (no gain in performance as all the related things 
still need to happen); but even that one would probably create the name 
in the same way

so ... this is the way it is ... (i must admit that it never gave me any 
issues so whatever triggered the question, there's probbaly a way around 
it)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2019-08-17  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-17  7:19 Henri Menke
2019-08-17  8:48 ` Hans Hagen [this message]
2019-08-17  8:56   ` Henri Menke
2019-08-17 10:15     ` Hans Hagen

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=c4f2f5b5-594b-c06d-fe15-9ff3f208f49f@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=henrimenke@gmail.com \
    --cc=ntg-context@ntg.nl \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).