On Wed, Dec 16, 2015 at 8:44 PM, konsolebox <konsole...@gmail.com> wrote: > > Just my quick thoughts: > > Pros: > 1) It could make code smaller. > 2) It could make writing code less prone to typos. > 3) It could make writing code faster.
thanks. that was exactly the idea behind it. > Cons: > 1) The constant assignments could slow down bash significantly but if > the string argument can simply be reused then maybe not. I can run some benchmarks, but I do not believe that another assignment/string duplication will slow down the test that much. > 2) It could make code look hacky or less readable like Perl's, > although it might depend on every user. sure. as usual. > > P.S. Because of this, I actually got an idea of using a variable for > storing values of optional arguments passed to `return`: > > function a { > return 0 a b c d # If no arguments are made, assign a static > empty array to `$.` to prevent slowdown when feature is not used. The > assigned array should be frozen, or perhaps readonly. # or just hidden. > } > a > echo "${.[@]}" # a b c d > > It would certainly be useful. I might create a patch and propose it > later if it's workable and efficient enough. thats interesting. actually now that you wrote this I started to think about a way to pass "array references" (or references to instances in general) to functions via special variables. That would require some object manager to be implemented, but we could to some extent pass array references. I wonder how much needs to be rewritten in order to get this working. sincerely, pg