Wed Jun 23 16:08:53 2010: Request 58579 was acted upon.
Transaction: Correspondence added by mark.doot...@znix.com
       Queue: Wx
     Subject: Re: [rt.cpan.org #58579] Compile Wx constants without exporting 
Wx constants
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: ad...@cpan.org
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=58579 >


I always found

use Wx qw(:sizer :window :id :misc :listctrl);

etc.

provides just the right level of control for my needs.



On 22/06/2010 12:27, Adam Kennedy via RT wrote:
> Tue Jun 22 07:27:02 2010: Request 58579 was acted upon.
> Transaction: Ticket created by ADAMK
>         Queue: Wx
>       Subject: Compile Wx constants without exporting Wx constants
>     Broken in: (no value)
>      Severity: (no value)
>         Owner: Nobody
>    Requestors: ad...@cpan.org
>        Status: new
>   Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=58579>
>
>
> A large Wx-based application will contains dozens or hundreds of classes
> that need to use Wx and the constants within it.
>
> Our experience from Padre suggests that the two main ways of consuming
> Wx constants don't scale.
>
> Firstly, you can suck in everything.
>
>   use Wx ':everything';
>
> This is just fine for a single class, but the sheer volume of symbols
> results in something like 50k of memory burnt.
>
> Multiply this by 20 classes and you end up with 1meg of RAM. Multiply it
> by 200 classes and you get 10meg of RAM, just to use the constants.
>
> The second and more efficient option is to name the specific symbols.
>
>    use Wx qw{
>        wxDefaultPosition
>        wxDefaultSize
>    };
>
> Unfortunately, this becomes highly unweildy at scale because of the
> heavy need for double maintenance and all the extra code that is
> required for no functional effect.
>
> The only effect all this import code has is to reduce the memory cost of
> accessing Wx constants.
>
> The problem is that you can't avoid doing this importing even if you
> want to.
>
> The following does not work.
>
>    use Wx ();
>
>    my $value = Wx::wxDefaultPosition;
>
> And yet this alternative DOES work...
>
>    use Wx ':everything';
>
>    my $value = Wx::wxDefaultPosition;
>
> In Padre, we work around this problem by having one master class import
> everything and in the process "stimulate" all the Wx::wxFOO constants
> into existing.
>
> All other Padre classes can then use any Wx::wxFOO constant with
> impunity. This is both computationally efficient, and reads pretty
> cleanly in the code itself.
>
> I would love to see some kind of similar effect implemented in Wx core
> itself, perhaps via a ':compile' type option.
>
> This would save Padre from importing all those symbols into Padre::Wx,
> and would greatly simplify code generators producing Wx code, because
> they don't have to track and import each constant used.
>
> Perhaps it would just be better to declare all the constants full all
> the time, or to declare all the constants consumed by a class (say,
> Wx::Dialog) by default whenever each class that can use them are loaded.
>
> It feels like there should be some way of doing this better than what is
> done now...


Reply via email to