[Developers] Perl API - just to make things confusing
Michael Jones
szaijan at gmail.com
Fri Aug 24 21:44:49 UTC 2007
Hi Tim,
On 8/24/07, Tim Sturge <tsturge at metaweb.com> wrote:
> Firstly thanks to everyone (Kirrily, Michael, Hayden) for working on this.
>
> I'm aware of the issue that some dynamic languages (python) distinguish
> quite strongly between string, int and float, some (javascript) between
> string and number and others (perl, PHP) don't really distinguish any of
> them. (The question mostly boils down to whether "55"+"11" is "5511" or 66).
>
> JSON distinguishes between string and number (as it is built on
> Javascript) and MQL distinguishes floats from integers (although it does
> automatically promote integers to floats when necessary). JSON and MQL
> also distinguish the boolean true as distinct from the integer 1 and the
> boolean false as distinct from the integer 0
>
> I'm wondering how much difficultly that will cause in Perl and PHP (not
> languages I have interfaced MQL to myself, but languages that we at
> Metaweb are 100% committed to working well with Freebase). So please let
> me know how this ends up working; I don't want MQL to impose unnecessary
> barriers to Perl (or PHP) users and if we need a "perl mode" then I
> would be willing to consider what its requirements would be.
In general, it would be useful if Metaweb would cast sumitted values
to their appropriate type, where possible. You already mentioned how
you "promote" integers to float, where approriate. Similarly, MW
converts strings to datetime, when that's expected. This same
approach could be taken with strings, where if a property expects a
string type, it would interpret a submitted number as an ascii string,
rather than dying. A nice touch would be if queries generated
warnings, as well as error messages, which could be a property of
successful response objects, and which would contain messages like
"Warning: Converted integer 2007 to the expected ascii string '2007'
in property "name" of query 'yearbook_write'."
I think a general approach like the above is consistant and much
better than an exceptions based approach, like the "Perl mode" hinted
at.
____________________________________________________________________
Michael Jones, Gamer at Large
szaijan at ternea.com
____________________________________________________________________
More information about the Developers
mailing list