[Circle-dev] Tangence Types

Paul LeoNerd Evans leonerd at leonerd.org.uk
Wed Nov 25 23:53:11 GMT 2009


On Wed, 25 Nov 2009 11:39:40 -0500
Kiyoshi Aman <kiyoshi.aman at gmail.com> wrote:

> Hi folks.
> 
> I've been looking at data types lately and wondering why we don't have
> a float/double type. It seems a strange oversight to me, if that's
> what it really is.

No particular reason yet, other than I hadn't needed them up until now,
so haven't really given it much thought.

I suggest taking perhaps the top two of the subtypes in DATATYPE_NUMBER
for that.

As for the bit-level encoding, that might be more interesting. There's
not standard "agreed" way to encode 32-bit or 64-bit floats down the wire.

A common format might be to take what libpack does, stolen from

 http://www.beej.us/guide/bgnet/output/html/multipage/advanced.html#serialization

Namely, to convert a 32-bit or 64-bit float into sign/exponent/mantissa
form, then encode these down the wire in a bit structure. This should be
compatible with IEEE 754.. Other systems may vary, but in practice we're
unlikely to encounter those. "Best effort on floats" perhaps might be a
wise warning...

> Also, I've been wondering if it would be feasible to support
> BER-encoded integers, since that would enable integer types to be as
> long as needed, and thusly eliminate the need for code to shoehorn
> integers into fixed sizes.

I've never quite liked BER. How about instead an "arbitrary precision
integer" which encodes its length beforehand, then encodes that number of
bytes. The problem with BER is you have to inspect every byte to see how
long it is, whereas a length prefix means you can skip over the actual
data in bulk.

> That's about it for now (although I've been pondering an 'index'
> type...) on the type front.

Index type..?

> (Incidentally, I've implemented a Pythonic take on Perl's 'scalar'
> type, mostly out of boredom. I don't really see why anyone would need
> it, though, in a language that has tuples.)

I'm not sure I follow here - how does "scalar" relate to tuples?

-- 
Paul "LeoNerd" Evans

leonerd at leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.leonerd.org.uk/pipermail/circle-dev/attachments/20091125/feff42d3/attachment.pgp>


More information about the Circle-dev mailing list