SrcLoc/SrcSpan/Located naming
Simon Marlow
marlowsd at gmail.com
Tue Jul 21 04:05:11 EDT 2009
We're at the stage where the GHC API is beginning to settle down a bit,
so it might be a good idea to keep backwards compatibility where
possible. If we rename things, we can leave the old names in, but
DEPRECATED, for one release.
Cheers,
Simon
On 20/07/2009 19:51, Isaac Dupree wrote:
> Do we make any attempt to keep the GHC API consistent between major
> releases, or is the policy generally just to make any naming changes
> that we find fitting for GHC's purposes?
>
> -Isaac
>
>
> Thomas Schilling wrote:
>> I think the inconsistencies are mostly because SrcSpan was added
>> later. Patches to improve the problematic cases would (most likely)
>> be welcome.
>>
>> 2009/7/20 Isaac Dupree <ml at isaac.cedarswampstudios.org>:
>>> is a confusing mess!
>>> The most important module is named SrcLoc, which is acceptable.
>>> It contains three types,
>>> SrcLoc,
>>> SrcSpan, which approximately is two SrcLocs (begin and end),
>>> and Located, which combines a SrcSpan (not a SrcLoc!) with an arbitrary
>>> other type.
>>>
>>> In practice (well, in my case at least) you almost always want a
>>> SrcSpan and
>>> not a SrcLoc.
>>> Many of the functions on SrcLoc have "srcLoc" in their names, which
>>> is good.
>>>
>>> However, so do many of the functions on Located-and-SrcSpan, which is
>>> terrible. It gets a little worse when you combine with the (fairly
>>> sensibly
>>> named functions) at Name.NamedThing
>>> noLoc, getLoc, addCLoc, combineLocs work on Locateds.
>>> noSrcLoc, getSrcLoc, work on SrcLocs. Instead, noSrcSpan and
>>> getSrcSpan are
>>> the ones you want.
>>>
>>> Okay it's not quite as bad as I thought. You want to avoid a function
>>> iff
>>> it contains the whole phrase "srcLoc". But I still got confused a lot of
>>> times. I wonder if we could rename something so that SrcLoc and Located
>>> don't have the same word-part in them, because they aren't really
>>> closely
>>> enough related? Even if it's just renaming "SrcLoc" to "SrcSpot" or
>>> something.
>>>
>>> It's also annoying that Name.getSrcSpan doesn't work on Locateds
>>> (inevitable
>>> I guess since it's type-different from NamedThing), but the function you
>>> have to use instead is called getLoc, even though it also produces a
>>> SrcSpan
>>> (only the argument-type is different). Hmm.
>>>
>>> -Isaac
>>>
>>> _______________________________________________
>>> Cvs-ghc mailing list
>>> Cvs-ghc at haskell.org
>>> http://www.haskell.org/mailman/listinfo/cvs-ghc
>>>
>>
>>
>>
>
> _______________________________________________
> Cvs-ghc mailing list
> Cvs-ghc at haskell.org
> http://www.haskell.org/mailman/listinfo/cvs-ghc
More information about the Cvs-ghc
mailing list