[Gdal-dev] Bool vs int in bindings?

Simon Perkins sy at perkins.net
Tue Apr 3 12:40:55 EDT 2007


Hi Howard and Tamas,

Thanks for putting me straight on this. You've convinced me!

I shall suppress my overdeveloped aesthetic sense and continue to be 
grateful that I can use the splendid GDAL library with C# so easily...

Cheers!

Sy


Howard Butler wrote:
> Simon,
>
> Regarding the booleans, I am pretty strongly against this idea because 
> it would mean a lot of divergent maintenance for languages that 
> *don't* support boolean types, and GDAL itself uses ints which would 
> mean we would have to have language-specific coercion.  It seems like 
> a lot of pain for little benefit.
>
> Regarding renaming, I'm ok with proper namespaces and using enums, but 
> language-specific renames to follow its language conventions seems 
> like a road to hell paved with good intentions.  I agree that 
> GDAL/OGR's swig bindings are indeed rough in some places and are often 
> not ideal as far as ease of use and following the norms of all of the 
> languages it supports.  In my opinion, the purpose of the swig 
> bindings is not to provide an ideal development library for geographic 
> data manipulation in every language supported -- instead its purpose 
> is to provide *access* to the GDAL/OGR/OSR facilities in as many 
> languages as possible.  This means compromise in a number of areas, 
> with naming conventions, calling conventions, and many language norms 
> being some of them.
>
> One approach you might take if you are wishing to smooth over the 
> rough spots of the swig bindings in your language is to develop a 
> wrapper library.  For example, the Python Cartographic Library 
> provides a more unified approach to data access, including GDAL/OGR 
> through wrapping the swig API, and it more closely follows Python's 
> language norms in the process.
>
> SWIG^H^H^H^Hcompromise-is-the-art-of-spreading-misery-ly y'rs*
>
> Howard
>
> *<http://www.amk.ca/quotations/python-quotes/page-10>
>
> On Apr 3, 2007, at 12:01 AM, Simon Perkins wrote:
>
>> Hi,
>>
>> A lot of the SWIG generated binding functions use ints as arguments 
>> and return types when a boolean type would be more appropriate, e.g. 
>> the OGR Open() method takes an int as the second argument to indicate 
>> whether the file should be opened with update access, and the 
>> SpatialReference.IsGeographic() method returns an int. It would be 
>> nice to use a more natural bool in these cases for languages that 
>> support it.
>>
>> Would I be right in thinking that there's pretty much no way of 
>> changing this now without breaking a lot of code? What about just 
>> changing it for some of the newer bindings, e.g. C#, that have 
>> recently had breaking API changes applied anyway. I like the new 
>> enums, etc for the C# bindings in place of int constants, can we fix 
>> the bool vs int problem there as well? I'd be happy to do this if 
>> people want to fix it, and Tamas doesn't have time.
>>
>> And while we're changing this, should wkbGeometryType be 
>> WkbGeometryType?
>>
>> Cheers,
>>
>> Simon
>>
>> _______________________________________________
>> Gdal-dev mailing list
>> Gdal-dev at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/gdal-dev
>>
>




More information about the Gdal-dev mailing list