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
Using the calltrace information is a fragile way to get location information -- in particular it requires programs to be compiled with -g. You should consider also providing an API that allows user to pass a location explicitly (and I would argue that the short name on the "path of least effort" should be this function, with eg. journal_send_implicit for the callstack-inspecting version).
Locations can be passed manually after having been inserted automatically by a syntactic processing pass (eg. one could think of a [%located journal_send] foo bar extension).
As of 4.02, OCaml provides the (admittedly under-documented, and of debatable elegance) __LOC__, __FILE__ and __LINE__ macros. so you could just encourage users to consistently write journal_send __LOC__ ... without the syntactic sugar.
Note that beside removing the requirement to consistently use -g, this gives user more control on the reported location. In particular, if (as a library user) you define auxiliary functions to perform the logging, you may want to report the location of the caller function instead, and letting user explicitly manipulate location as first-class values gives them the flexibility to decide this.
The text was updated successfully, but these errors were encountered:
Using the calltrace information is a fragile way to get location information -- in particular it requires programs to be compiled with
-g
. You should consider also providing an API that allows user to pass a location explicitly (and I would argue that the short name on the "path of least effort" should be this function, with eg.journal_send_implicit
for the callstack-inspecting version).Locations can be passed manually after having been inserted automatically by a syntactic processing pass (eg. one could think of a
[%located journal_send] foo bar
extension).As of 4.02, OCaml provides the (admittedly under-documented, and of debatable elegance)
__LOC__
,__FILE__
and__LINE__
macros. so you could just encourage users to consistently writejournal_send __LOC__ ...
without the syntactic sugar.Note that beside removing the requirement to consistently use
-g
, this gives user more control on the reported location. In particular, if (as a library user) you define auxiliary functions to perform the logging, you may want to report the location of the caller function instead, and letting user explicitly manipulate location as first-class values gives them the flexibility to decide this.The text was updated successfully, but these errors were encountered: