public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: vapier@gentoo.org
Subject: Re: [gentoo-dev] evar_push/pop helpers
Date: Sun, 2 Jun 2013 10:39:32 +0200	[thread overview]
Message-ID: <20130602103932.759bee82@gentoo.org> (raw)
In-Reply-To: <201306020329.34579.vapier@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 2511 bytes --]

Dnia 2013-06-02, o godz. 03:29:33
Mike Frysinger <vapier@gentoo.org> napisał(a):

> On Sunday 02 June 2013 03:16:53 Michał Górny wrote:
> > Dnia 2013-06-02, o godz. 03:09:31 Mike Frysinger napisał(a):
> > > On Sunday 02 June 2013 02:51:34 Michał Górny wrote:
> > > > Dnia 2013-06-01, o godz. 23:03:20 Mike Frysinger napisał(a):
> > > > > simple set of helpers to save/restore a variable in a limited section
> > > > > of code
> > > > > 
> > > > > you can see an example of it in action at the end of the file where i
> > > > > need to tweak epatch (and no, doing `LC_COLLATE=C set -- ....` does
> > > > > not work).
> > > > 
> > > > Why the ugly hackery instead of proper 'local' scope?
> > > 
> > > there's no way to undo the local thus it affects the rest of the func. 
> > > this makes sure the change is actually localized to where it is needed.
> > 
> > By use of global variables and a bunch of additional code and evals.
> 
> the implementation details of estack_* doesn't matter

It's not beautiful language with proper local scopes, so it *does*
matter.

> > Is:
> > 
> >   local _epatch_foo=${foo}
> >   local foo
> >   ...
> >   foo=${_epatch_foo}
> > 
> > really that hurtful?
> 
> except you aren't handling edge cases (like set vs unset), and i've replicated 
> this pattern before (in fact, you've filed bugs where the set/unset case wasn't 
> handled).  API 101: implement it once correctly to simplify everyone else.

Edge cases matter where they actually matter. Inventing use cases just
to prove we need something doesn't help anyone.

And we can't implement it correctly since we're talking about bash.
Bash doesn't provide means to implement it correctly.

> > Also, do you really want the collation to be changed only in this one
> > place? This looks weird to me.
> 
> yes, i only want to force it here, because it's the only place where collation 
> matters in the func currently.

So, effectively, changing it once in the beginning of the function
would be simpler and wouldn't cost anything.

> 
> > Much like fixing tiny bug and trying to
> > avoid checking whether anything else is affected.
> 
> yeah, because forcing specific behavior for an entire function is always the 
> correct answer.  it's like telling people to export LC_ALL=C in make.conf so 
> they never hit locale related problems.

Feel free to try that. But on yourself, not our users. Or just grep
bugzie.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

  parent reply	other threads:[~2013-06-02  8:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-02  3:03 [gentoo-dev] evar_push/pop helpers Mike Frysinger
2013-06-02  6:51 ` Michał Górny
2013-06-02  7:09   ` Mike Frysinger
2013-06-02  7:16     ` Michał Górny
2013-06-02  7:29       ` Mike Frysinger
2013-06-02  7:48         ` Tom Wijsman
2013-06-17  5:45           ` Mike Frysinger
2013-06-02  8:39         ` Michał Górny [this message]
2013-06-02 15:40           ` Mike Frysinger
2013-06-02 15:57             ` Andreas K. Huettel
2013-06-02  7:33     ` Tom Wijsman
2013-06-02 17:38 ` [gentoo-dev] " Steven J. Long
2013-06-17  5:42   ` Mike Frysinger
2013-06-17 16:06     ` Mike Frysinger
2013-06-17  5:46 ` [gentoo-dev] " Mike Frysinger
2013-06-17 17:51   ` Greg KH

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=20130602103932.759bee82@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=vapier@gentoo.org \
    /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