> From: avih [mailto:avih...@yahoo.com]
> Sent: Wednesday, April 24, 2019 8:16 PM
> To: Guo, Yejun <yejun....@intel.com>; FFmpeg development discussions and
> patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH V4 2/2] configure: replace 'pr' with printf
> since busybox does not support pr
> 
> > how about add the keyword local which makes the variables not global.
> 
> No. It's not portable and not standard, and will break with a lot of shells
> which ffmpeg currently supports.
> 
> Different shells have different ways to limit a variable scope to the current
> function, some don't have a way at all, and some limits some variables
> automatically (like the value variable in a `for` command).
> 
> There are only two standard ways for limited-scope values:
> 
> - A function's positional parameters are local to each instance (including
>   each instance in a recursion).
> 
> - A subshell prevents all changes to variables outside of it, with two issues:
>     1. Code can't actually modify any variables outside of its subshell...
>     2. It can be very expensive where/if (a big if) performance matters.
> 
> There are ways to implement locality of variables while staying portable. In
> ffmpeg's configure `pushvar` and `popvar` were used for such functionality
> (they still exist in configure but currently unused). Their usage was
> replaced with a method based on storing prior values in positional parameter
> (in a recursive function) and restoring them later.
> 
> There are also more generic solutions, with varying degrees of complexity and
> performance. I wrote such solution myself, and some day I might send a patch
> to ffmpeg which incorporates it.
> 
> Till then, there's no generic way to set local variables in `configure`
> except the two methods mentioned above, or using a unique enough name.
> 

thanks a lot for your nice explanation, I'll use the unique enough name.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to