mfp / extprot

extprot: extensible binary protocols for cross-language communication and long-term serialization
Other
209 stars 9 forks source link

name clash when using external types #2

Closed ygrek closed 9 years ago

ygrek commented 13 years ago

consider

type url = string options "ocaml.type" = "Url.t, Url.parse_exn, Url.show"

this will generate module Url with type Url.url = Url.t while the following generated code will reference Url.t directly which is not in scope now because generated Url module hides the external one.

mfp commented 11 years ago

I know this comes two years late, but here it goes for the record:

using a different alias, annoying as it might be, seems a reasonable workaround in this case

type url_ = ...

The ocaml type is "inlined", so that references to url_ in the protocol become Url.t in the generated type definitions. The one remaining annoyance outside the proto is that the generated pp_url_ function includes the trailing underscore, but these functions are sort of an inner implementation detail anyway, as the user is only supposed to use messages externally.

ygrek commented 9 years ago

yes, this works and that's what I ended up using