- Home /
Are named parameters supported?
Are named parameters supported? When I tried to use them in my code, I got a vague "internal compiler error" in the Unity console log.
Unhandled Exception: $$anonymous$$ono.CSharp.InternalErrorException: Internal error
at $$anonymous$$ono.CSharp.$$anonymous$$ethodGroupExpr.IsApplicable ($$anonymous$$ono.CSharp.ResolveContext ec, $$anonymous$$ono.CSharp.Arguments& arguments, Int32 arg_count, System.Reflection.$$anonymous$$ethodBase& method, System.Boolean& params_expanded_form) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.$$anonymous$$ethodGroupExpr.OverloadResolve ($$anonymous$$ono.CSharp.ResolveContext ec, $$anonymous$$ono.CSharp.Arguments& Arguments, Boolean may_fail, Location loc) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.New.DoResolve ($$anonymous$$ono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Expression.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Expression.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Argument.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Arguments.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec, System.Boolean& dynamic) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Invocation.DoResolve ($$anonymous$$ono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Expression.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Expression.Resolve ($$anonymous$$ono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.ExpressionStatement.ResolveStatement ($$anonymous$$ono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.StatementExpression.Resolve ($$anonymous$$ono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Block.Resolve ($$anonymous$$ono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.ToplevelBlock.Resolve ($$anonymous$$ono.CSharp.FlowBranching parent, $$anonymous$$ono.CSharp.BlockContext rc, $$anonymous$$ono.CSharp.ParametersCompiled ip, I$$anonymous$$ethodData md) [0x00000] in <filename unknown>:0
A piece of code to replicate the error would be great too.
Well mainly I wanted to know if they're supported or not in Unity 3D/$$anonymous$$onoDevelop. If they aren't, I just won't use them. If they are, then I know I'm doing something wrong on my end.
Answer by tw1st3d · Oct 06, 2013 at 06:26 PM
After a little bit of research, it's looking like Unity does support named parameters. However, I may be incorrect, so you should do more research yourself.
I'm doing some more testing on my end. It might be because I'm using default parameters as well, but with the named parameters, I had coincidentally set them in a different order from the parameter list
The example in Named Arguments works for me, but maybe it's a different thing... You should post your code so we know what we're talking about here.
With named arguments it shouldn't matter what order you give them in, as long as no unnamed arguments follow.
@Nezabyte If this is this answer is correct, would you $$anonymous$$d ticking it? :)
Its fine if you solved it, don't worry about the code. You haven't however ticked this answer because it's not green. To mark this answer as correct, click the currently gray checkmark below the thumbs.
I'd be quite interested to see the code, actually, to see what was wrong. I know that named and optional parameters both require being placed at the end of the argument tuple (so that there are no unnamed parameters after a named one, and no obligatory arguments after an optional one), but other than that I'm not sure what would be causing the error. Unless of course the error was caused by that setup, in which case it's fine.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Disabling A Script on a GameObject From a Different Script 2 Answers
Sync with visual studio 2010 error 1 Answer