A few holes (imho) in the ecosystem of libraries
Guillaume Piolat
first.last at spam.org
Mon May 15 13:53:15 UTC 2023
On Monday, 15 May 2023 at 13:38:12 UTC, Andrew wrote:
> On Monday, 15 May 2023 at 13:04:57 UTC, Guillaume Piolat wrote:
>> 2. A I/O abstraction really suitable for parsing/emitting
>
> Regarding your second point, I noticed this was limiting me
> recently, so I've been working in the evenings on a
> proof-of-concept for what this could look like if added to
> Phobos in the same style as ranges:
> https://forum.dlang.org/thread/okoaghstghyxapqcwbtr@forum.dlang.org
I'll take an example.
My current TGA parsing looks like this ugly:
bool getImageInfo(IO* io, IOHandle _handle)
{
// Taken right from stb_image.h
bool err;
_dataOffset = _io.read_ubyte(_handle, &err);
if (err)
return false;
_cmapType = _io.read_ubyte(_handle, &err);
if (err || _cmapType > 1)
return false; // only RGB or indexed allowed
_imageType = _io.read_ubyte(_handle, &err);
if (err) return false;
/// ...more parsing...
}
What I would really want is:
bool getImageInfo(IO* io)
{
_dataOffset = _io.read_ubyte();
_cmapType = _io.read_ubyte();
_imageType = _io.read_ubyte();
return !_io.error;
}
Can't use exceptions since downstream user will use that on
WebASM, -betterC not having class etc.
And I cannot use your library for similar reasons, it uses the
runtime, it uses exceptions, it has generic names etc. We have a
lot of such libraries, but we have to keep in mind people use D
because they are performance-oriented and they may have druntime
constraints. Ideally the D runtime would be pay-as-you-go and
infinitely portable, but that's not the current state of things.
More information about the Digitalmars-d
mailing list