[m-dev.] shims

Paul Bone paul at bone.id.au
Mon Sep 15 12:05:15 AEST 2014


On Sun, Sep 14, 2014 at 12:51:44PM +1000, Mark Brown wrote:
> 
> Here's another approach that I think provides an interesting solution.
> Namely, a top level construct of the following abstract form:
> 
>     if
>         declarations
>     then
>         items
>     else if
>         declarations
>     then
>         items
>     ...
>     else
>         items
>     end if
> 

This is a very interesting suggestion and I think should be considered.  I
like it because of the checking and because of the flexability it provides.
However I'm concerned that language features like this will be used as a
crutch.  It'd be very easy when adding features to a library that uses
conditional compilation to add features to the the branches that you're
using and testing against end then pass that code to a colleague (or use it
years later) and not notice that feature X isn't implemented because library
Y's API has changed.

In many ways I prefer the compiler to complain loudly, but at the same time
I understand that someone might lagitimatly want to support compiling
against multiple versions of the same library or different libraries that
provide the same functionality differently (eg: OpenSSL vs GNUTLS).

Another option, although I think this is less acheiveable in the short term,
is to require that all libraries provide semantic versioning, and that when
you :- import_module you may specify a specific version, or use conditional
compilation that's predicated on a library's version.

:- if.
    :- import_module set ver(1.1).

    ... use the new feature in set 1.1
:- else if.
    :- import_module set ver(1.0).
    
    ... write slower/longer code due to the unavailable feature.
:- else.
:- end if.


About semantic versioning: http://semver.org/


-- 
Paul Bone



More information about the developers mailing list