Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
|
Leaves
This morning, the bud of the little magnolia
plant has opened. I took a picture of it in the sun.
Book from Het Goed
Yesterday, I discovered that the local charity
shop Het Goed carries a rather large and reasonable good collection of
secondhand books for rather good prices. This afternoon, at 15:35, I bought
the book Steve Jobs: de biografie by Walter
Isaacson for € 2.00 (including a € 0.50 tip).
Three leaves
Our magnolia plant now has three leaves and
more are coming.
Natural wells
This morning, I took pictures of the four places where water from natural is
often flowing. Recently, a new place has appeared along the byclicle path.
(See number 1 on the picture on the right.) They dug some hole beside the
path that is now filled up with water. Three years
ago they installed some drainage from about this spot till even a little
further than the traffic lights for the bikes to cross the road (see number
2), but it seems that for some reason it is not working anymore. Near the
traffic light and across the road there is often water flowing. A little
further (number 4) there is a place where water is also welling up. This
is one of the old places where the water was coming out of the ground. Two
other places a little further along the road (that I reported about on
April 7, 2009) seem to have dried up. In the
past year some ground work has been performed in the area to replace the
existing sewer drains.
(Follow-up: New well)
Filter language construct
New languages are invented all the time in the field of software engineering. Most of these languages are just a variation
on existing languages reusing existing concepts in new combinations.
Recently, I got the idea for introducing a filter concept that processes
a stream of data into another form. (Can imagine that I am the first one
to get this idea, but I do not know of a language that uses it.) I would
like to use the UTF-8 decoding as an example, that takes a stream of bytes
values and turn them into Unicode code points. In progamming languages, filters are implemented
as pull or push algorithms. In the pull algorithm you implement some
function or method that from a stream of bytes, retrieves the next Unicode
character (code point), while in the push algorithm you implement a
function or method that you feed bytes and that emits a Unicode (code
point) to a file or appends it to the end of a string. The specification
of a filter should be such that it is agnostic to the pull or push
implementation and the language should have constructs where the use of
the filter automatically implements the pull or push algorithm. Below the
specification of the example filter in an extension of
C++ that uses new
keywords filter, consume, and emit.
filter UTF8ToUnicodeDecoder(byte, UnicodeChar)
{
byte v = consume;
if (value < 0x80) {
emit UnicodeChar(v);
}
else
{
int _code_point;
int _following;
if ((value & 0xFC) == 0xF8) {
_code_point = v & 0x07;
_following = 4;
}
else if ((value & 0xF8) == 0xF0) {
_code_point = v & 0x0F;
_following = 3;
}
else if ((value & 0xF0) == 0xE0) {
_code_point = v & 0x1F;
_following = 2;
}
else if ((value & 0xE0) == 0xC0) {
_code_point = v & 0x3F;
_following = 1;
}
else {
return; // error: not a valid start byte
}
for (; _following > 0; _following--)
{
v = consume;
if ((v & 0xC0) != 0x80) {
return; // error: not a valid following byte
}
_code_point = (codepoint << 6) | (v & 0x7F);
}
emit UnicodeChar(_code_point);
}
};
I have not thought yet about syntax constructs for using the filter. The
language should at least have an iterator concept (for the pull algorithm),
a stream concept (for the push algorithm), and/or have pipe statements like
in most Unix shells. In the above filter specification there are also a
number of error conditions that can occur. Because there are many ways
with dealing with errors, the error handling might depend on the context
in which the filter is being used. Ideally, one would have some mechanism
to specify the error handling at the place where the filter is used.
I recently, implemented the push algorithm in a C++ class in the following
manner, when working on new version of IParse:
class UTF8ToUnicodeConverterStream : public ConverterStream<char, UnicodeChar>
{
public:
UTF8ToUnicodeConverterStream() : _following(0) {}
virtual void emit(const char symbol)
{
unsigned char value = (unsigned char)symbol;
if ((value & 0xC0) == 0x80) {
if (_following == 0) {
// error: out of place following char
return;
}
_code_point = (_code_point << 6) | (value & 0x3F);
if (--_following == 0)
_out->emit(_code_point);
return;
}
if (_following > 0) {
// error: expecting more following chars
_following = 0;
return;
}
if ((value & 0x80) == 0x00) {
_out->emit(value);
}
else if ((value & 0xE0) == 0xC0) {
_code_point = value & 0x1F;
_following = 1;
}
else if ((value & 0xF0) == 0xE0) {
_code_point = value & 0x0F;
_following = 2;
}
else if ((value & 0xF8) == 0xF0) {
_code_point = value & 0x07;
_following = 3;
}
else if ((value & 0xFC) == 0xF8) {
_code_point = value & 0x03;
_following = 4;
}
else {
// error: incorrect start character
}
}
private:
int _following;
UnicodeChar _code_point;
};
Diary Frida Vogels
At 9:47, I bought the book Frida Vogels. Dagboek 1970-1971 by Frida Vogels
for € 14.95 from bookshop Broekhuis.
Most of the time it takes me a long time to consider to buy a book, mostly ending
up not buying the book, and at other times, it takes me a few seconds to decided.
I have a weakness for diaries and (auto)biographic works.
This months interesting links
Home
| Februari 2015
| April 2015
| Random memories