You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think one of the most common use-cases for Reflect.makeVarArgs() would be for logging tools, and in the same breath one of the most common use-cases for haxe.PosInfos would be the usage in debug tools and loggers as well, since we can read out the line numbers of the call.
However those 2 don"t work well together, although you would expect that that"s how trace() works under the hood :
It can take any number of arguments
The last argument is PosInfos
Now currently if you want to replicate that behaviour, the only way is to redefine trace(). But in html5, you might not want to do that, since you don"t want to just log out to console.log - you want to log out to console.warn, console.error, console.debug, console.info etc. - and of course you want to attach the line number of the call to it.
So assuming there"s no other way to have a function with an arbitrary amount of arguments + haxe.PosInfos attached to it ( as it is in trace ), I would propose to add a @:posInfos metadata, that passes on haxe.PosInfos as the last parameter to a function when it"s called.
This would also make the usage of trace() more standard and understandable, and would help with alternative logger solutions without them all having to redefine trace and possibly colliding with each other.
If I"ve missed anything and there is actually another alternative solution please feel free to play around with this example : https://try.haxe.org/#361D7
The text was updated successfully, but these errors were encountered:
mastef
changed the title
@:posInfos to pass haxe.PosInfos to Reflect.makeVarArgs()
@:posInfos to pass haxe.PosInfos to Reflect.makeVarArgs()
Oct 21, 2017
I think one of the most common use-cases for
Reflect.makeVarArgs()
would be for logging tools, and in the same breath one of the most common use-cases forhaxe.PosInfos
would be the usage in debug tools and loggers as well, since we can read out the line numbers of the call.However those 2 don"t work well together, although you would expect that that"s how
trace()
works under the hood :PosInfos
Now currently if you want to replicate that behaviour, the only way is to redefine
trace()
. But in html5, you might not want to do that, since you don"t want to just log out toconsole.log
- you want to log out toconsole.warn
,console.error
,console.debug
,console.info
etc. - and of course you want to attach the line number of the call to it.So assuming there"s no other way to have a function with an arbitrary amount of arguments +
haxe.PosInfos
attached to it ( as it is intrace
), I would propose to add a@:posInfos
metadata, that passes onhaxe.PosInfos
as the last parameter to a function when it"s called.This would also make the usage of
trace()
more standard and understandable, and would help with alternative logger solutions without them all having to redefinetrace
and possibly colliding with each other.If I"ve missed anything and there is actually another alternative solution please feel free to play around with this example : https://try.haxe.org/#361D7
The text was updated successfully, but these errors were encountered: