On 06/03/2015 12:12 AM, Seth Fowler wrote:
On Jun 2, 2015, at 1:59 PM, L. David Baron <dba...@dbaron.org> wrote:
Remember that if 'auto' is forbidden, people might get around it by
not using a variable at all (and instead repeating the expression)
rather than by writing the type explicitly on the variable... and
this doesn't provide type information.
This is a point that’s worth calling out explicitly. When you write this:
Foo(Bar());
You do not have to explicitly specify the return type of Bar(), and if you
change both the return type of Bar() and the type of Foo()’s first parameter,
you don’t have to update this callsite.
If you write this:
Baz val = Bar();
Foo(val);
Now you’ve been forced to explicitly write out the return type of Bar()
And this might not always be easy to write it down, or it might be
redundant, especially if this return type is constructed based on the type
of the arguments of the function.
This pattern is used to build a variadic list of argument in the
CodeGenerator of IonMonkey. The type is mostly uninteresting, as this is
the repeated type of the arguments.
Taking a real example [1], this code:
OutOfLineCode* ool =
oolCallVM(…, (ArgList(), ImmGCPtr(info.fun), scopeChain), …);
would become:
ArgSeq<ArgSeq<ArgSeq<void,void>, ImmGCPtr>, Register>& args =
(ArgList(), ImmGCPtr(info.fun), scopeChain);
OutOfLineCode* ool = oolCallVM(…, args, …);
which is way too verbose for repeated type information.
[1]
https://dxr.mozilla.org/mozilla-central/source/js/src/jit/CodeGenerator.cpp#1704
PS: Yes, we can use variadic templates now … Bug 1168500
--
Nicolas B. Pierron
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform