cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: clone and overrides


From: Gary Oberbrunner
Subject: RE: clone and overrides
Date: Mon, 22 Oct 2001 11:17:00 -0400

At first I thought this would be great.  But it would have to be optional,
because sometimes you WANT to put a %-string into a cloned env.  Maybe a
clone_subst() method.  Also I think you might only want to do one level of
%-substitution; deep-substituting all the %s during the clone could be wrong
if you're intending to use that env as the source for some other one later.

These days I mostly use $env->copy(); it's more flexible because you can
change the hash arbitrarily, although it's more verbose.

 my %t = $env->copy();
 $t{CFLAGS} .= '-DMISSIONPACK'; # Not quite same as original example
 $e2 = $e1->clone(%t);

-- Gary Oberbrunner



 > -----Original Message-----
 > From: address@hidden [mailto:address@hidden
 > Behalf Of Steven Knight
 > Sent: Saturday, October 20, 2001 6:52 PM
 > To: Timothee Besset
 > Cc: address@hidden
 > Subject: Re: clone and overrides
 >
 >
 > > I'm trying to create a new cons environment from an existing one, and
 > > modify some of the variables. I tried the following:
 > >
 > > $vm_ta_env = $vm_env->clone(
 > >   CFLAGS => '-DMISSIONPACK ' . $CFLAGS
 > >   );
 >
 > The above would expand the *Perl* variable $CFLAGS, not the environment
 > construction variable %CFLAGS.  Hence, nothing gets appended.  *If*
 > clone() expanded construction variables, the way to do it would be:
 >
 >      $vm_ta_env = $vm_env->clone(
 >              CFLAGS => '-DMISSIONPACK %CFLAGS'
 >      );
 >
 > But clone() doesn't expand construction variables...
 >
 > > I end up with a $CFLAGS that only holds '-DMISSIONPACK ', I had to find
 > > another way to get what I wanted:
 > >
 > > %vm_ta_env_hash = $vm_env->copy();
 > > $vm_ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $vm_ta_env_hash{CFLAGS};
 > > $vm_ta_env = new cons(%vm_ta_env_hash);
 >
 > Here's a slightly less roundabout way to do what you want; fetch the
 > CFLAGS construction variable explicitly:
 >
 >      $vm_ta_env = $vm_env->clone(
 >              CFLAGS => '-DMISSIONPACK ' . $vm_env->{CFLAGS},
 >      );
 >
 > > Is there a reason why the clone() command doesn't override
 > correctly? Or
 > > is it a bug?
 >
 > It overrides "correctly," it's just never been defined to expand
 > construction variables within the overridden values.  That would be an
 > attractive enhancement.
 >
 >      --SK
 >
 >
 > _______________________________________________
 > address@hidden
 > http://mail.gnu.org/mailman/listinfo/cons-discuss
 > Cons URL: http://www.dsmit.com/cons/
 >




reply via email to

[Prev in Thread] Current Thread [Next in Thread]