January was made the first month around 153 BC. Before then
January was the 12th month and February was the 11th month.
January is named after Januus, who is two-faced so he can
look at the year past and the year to-come. I think that
the idea was to get the new year running after the solstice,
which was then the 25th day of a 29-day December.
Between then until Caesar changed things, the months were
January February March April May June Quintilis Sextilis
September October November December, alternating 30 and 29
days.
An extra month, usually called Mercedonius, alternating 22 or
23 days, was supposed to be inserted six days before the end
of February every other year.
For political reasons the people who were supposed to proclaim
the extra month, often did not.
By 47 BC (whatever it was called) the calendar was a 100
days early, so Caesar, with the advice of Sosigenes of Alexandria,
put 15 months in 46 BC: January February Mercedonius March
April May June Quintilis Sextilis September October November
December Undecember Duodecember.
In 45 BC things were supposed to be fixed, with the month of
Caesar's birth renamed July, and the days of the months
31 29 31 30 31 30 31 30 31 30 31 30, Every 4 years an extra
day was to be inserted before the 25 of February.
However they started by putting in a extra day every three years.
Augustus fixed this by saying that until they caught up there
would be no leap years. So there were no leap years between 12
BC and 8 AD. He renamed Sextilis after himself, took another
day from February, and changed the days in the months after
July.
forthwith
Monday, December 31, 2007
Why December is the Twelfth Month
A post by Wil Baden in comp.lang.forth, dated 1999:
Thursday, December 20, 2007
Low-Cost Multi-point Interactive Whiteboards Using the Wiimote
This is a really neat bit of inverted thinking.
A Nintendo Wii Remote can be used with an ordinary PC. It tracks its position in space relative to fixed infra-red light sources. It can work just as well if the sensor is static and the light sources move. Johnny Chung Lee demonstrates how a fixed Wiimote can track up to four points simultaneously, adding multitouch or head-tracking capabilities cheaply to any PC display.
A Nintendo Wii Remote can be used with an ordinary PC. It tracks its position in space relative to fixed infra-red light sources. It can work just as well if the sensor is static and the light sources move. Johnny Chung Lee demonstrates how a fixed Wiimote can track up to four points simultaneously, adding multitouch or head-tracking capabilities cheaply to any PC display.
Wednesday, December 19, 2007
Six Days of Creation
Six days from the Big Bang, each hour lasting approx 100 million years.
Earth appears in the last hour of the fourth day.
Oceans form by the start of the fifth day.
The ancestor of all living cells appears around the middle of the day, and by the start of the sixth day its descendants have filled the atmosphere with oxygen, and chloroplasts develop.
In the middle of the sixth day the first dry land appears. Two or three hours later, fungi appear, and plants an hour or so later.
With five or six hours to go to the end of the day, fish and insects.
Three hours to go - amphibians.
Three minutes later seed-bearing plants colonise the land and reptiles follow them 12 minutes later.
Two and a half hours to go - the Permian extinction, after which the dinosaurs develop.
By the start of the last hour there are flowering plants, and the first birds and mammals.
Forty minutes to go - the first grass appears, and shortly afterwards the big dinosaurs are gone.
Four minutes, last common ancestor of humans and chimps.
100 seconds, genus Homo.
One minute, controlled use of fire.
8 seconds, Homo sapiens
Recorded history, 1/5 of a second.
Earth appears in the last hour of the fourth day.
Oceans form by the start of the fifth day.
The ancestor of all living cells appears around the middle of the day, and by the start of the sixth day its descendants have filled the atmosphere with oxygen, and chloroplasts develop.
In the middle of the sixth day the first dry land appears. Two or three hours later, fungi appear, and plants an hour or so later.
With five or six hours to go to the end of the day, fish and insects.
Three hours to go - amphibians.
Three minutes later seed-bearing plants colonise the land and reptiles follow them 12 minutes later.
Two and a half hours to go - the Permian extinction, after which the dinosaurs develop.
By the start of the last hour there are flowering plants, and the first birds and mammals.
Forty minutes to go - the first grass appears, and shortly afterwards the big dinosaurs are gone.
Four minutes, last common ancestor of humans and chimps.
100 seconds, genus Homo.
One minute, controlled use of fire.
8 seconds, Homo sapiens
Recorded history, 1/5 of a second.
Friday, November 18, 2005
The Future of FIG UK
The FIG UK web site and the accompanying magazine Forthwrite has been dormant for some time now for lack of volunteers.
I've established a forum and it is possible, given enough interest, that Forthwrite will return in a new form. That interests you, and there is some way in which you can help, please get in touch.
I've established a forum and it is possible, given enough interest, that Forthwrite will return in a new form. That interests you, and there is some way in which you can help, please get in touch.
Wednesday, September 21, 2005
Mixing and Matching Control Structures
Forth uses IMMEDIATE words to build control structures at compile time. The various opening and closing words communicate with each other by passing items on a control stack to ensure proper nesting.
Sometimes, however, strict nesting is not what is needed, and the Standard provides the words CS-PICK and CS-ROLL to change the
order of items on the stack. (0 CS-ROLL is a no-op, 1 CS-ROLL is a swap; 0 CS-PICK is a dup, 1 CS-PICK is an over, and so on...). The details of the control stack and the size and format of items is implementation-dependant, but by far the most common choice is to use the data stack, with either one or two items for each item.
In the examples below I shall use CS-PICK and CS-ROLL explicitly, but they are intended to be used for the definition of new control structure words, as in the examples of ELSE and WHILE below:
: ELSE \ orig1 -- orig2
POSTPONE AHEAD \ orig1 orig2
1 CS-ROLL POSTPONE THEN ; \ consumes orig1
IMMEDIATE
: WHILE \ dest -- orig dest
POSTPONE IF 1 CS-ROLL ; IMMEDIATE
Using WHILE
BEGIN ... WHILE is normally resolved by REPEAT, which is another way of saying AGAIN THEN - but could also be closed with
... UNTIL do this on normal exit only THEN ...
and you can use multiple WHILEs within the loop, each resolved by its own THEN outside
BEGIN ... WHILE ... WHILE ... UNTIL ... THEN ... THEN
But you’ll notice that WHILE does not modify the dest on the top of the control stack. In fact, unless your Forth is overly pedantic, any other item will do as well. For example, in:
IF ... WHILE ... THEN ... THEN
(I don't recommend this - each time I look at it I have to work out again what it actually does).
Generally it is best to strictly nest both forward branches and loops, but it is sometimes useful to branch out of a loop (as in the examples above) or into the middle of a loop:
IF BEGIN maybe ignore first time [ 1 CS-ROLL ] THEN the rest of the loop UNTIL
WHILE may equally well be used to exit a DO ... LOOP, but here you need to use UNLOOP to get rid of the redundant loop index.
DO ... WHILE ... LOOP normal exit ELSE early exit UNLOOP THEN
is very messy, even more so with multiple WHILEs. It would be better to place the ELSE clauses within the loop, changing the sense of the test:
DO ... IF early exit UNLOOP ELSE [ 1 CS-ROLL ] ... LOOP normal exit THEN ...
Of course. if the definition ends at THEN, you can simply do an early return
DO ... IF early exit UNLOOP EXIT THEN ... LOOP normal exit
Or if you just want to exit the loop and perform whatever code follows in all cases:
DO ... IF early exit LEAVE THEN ... LOOP all exits
This can be done using CS-PICK. The simplest example mimics the Java’s continue keyword:
BEGIN ... WHILE ... [ 0 CS-PICK ] REPEAT ... UNTIL
DO ... WHILE ...[ 0 CS-PICK ] REPEAT ... LOOP
may possibly compile too, but is not guaranteed to work, since do-sys may not be identical to dest. In this case, since the loop counter is decremented by LOOP rather than DO, each time the program hits REPEAT it effectively repeats the same iteration.
The same trick can be used within a CASE statement. Suppose you want the same action for a range of values, with one exception:
CASE
exception OF do-exception ENDOF
DUP range WITHIN IF DROP do-range ELSE [ 1 CS-ROLL ]
...
ENDCASE
THEN
On some (perhaps most) Forths this is unnecessary, since OF is the strict equivalent of OVER IF DROP and so can be paired with THEN, or IF paired with ENDOF.
What goes on the control stack
- BEGIN leaves dest to be consumed by UNTIL or AGAIN
- AHEAD and IF leave orig to be consumed by THEN
- (AHEAD compiles an unconditional forward jump)
- DO and ?DO leave do-sys to be consumed by LOOP or +LOOP
- CASE leaves case-sys to be consumed by ENDCASE
- OF leaves of-sys to be consumed by ENDOF
Sometimes, however, strict nesting is not what is needed, and the Standard provides the words CS-PICK and CS-ROLL to change the
order of items on the stack. (0 CS-ROLL is a no-op, 1 CS-ROLL is a swap; 0 CS-PICK is a dup, 1 CS-PICK is an over, and so on...). The details of the control stack and the size and format of items is implementation-dependant, but by far the most common choice is to use the data stack, with either one or two items for each item.
In the examples below I shall use CS-PICK and CS-ROLL explicitly, but they are intended to be used for the definition of new control structure words, as in the examples of ELSE and WHILE below:
: ELSE \ orig1 -- orig2
POSTPONE AHEAD \ orig1 orig2
1 CS-ROLL POSTPONE THEN ; \ consumes orig1
IMMEDIATE
: WHILE \ dest -- orig dest
POSTPONE IF 1 CS-ROLL ; IMMEDIATE
Using WHILE
BEGIN ... WHILE is normally resolved by REPEAT, which is another way of saying AGAIN THEN - but could also be closed with
... UNTIL do this on normal exit only THEN ...
and you can use multiple WHILEs within the loop, each resolved by its own THEN outside
BEGIN ... WHILE ... WHILE ... UNTIL ... THEN ... THEN
But you’ll notice that WHILE does not modify the dest on the top of the control stack. In fact, unless your Forth is overly pedantic, any other item will do as well. For example, in:
IF ... WHILE ... THEN ... THEN
(I don't recommend this - each time I look at it I have to work out again what it actually does).
Generally it is best to strictly nest both forward branches and loops, but it is sometimes useful to branch out of a loop (as in the examples above) or into the middle of a loop:
IF BEGIN maybe ignore first time [ 1 CS-ROLL ] THEN the rest of the loop UNTIL
WHILE may equally well be used to exit a DO ... LOOP, but here you need to use UNLOOP to get rid of the redundant loop index.
DO ... WHILE ... LOOP normal exit ELSE early exit UNLOOP THEN
is very messy, even more so with multiple WHILEs. It would be better to place the ELSE clauses within the loop, changing the sense of the test:
DO ... IF early exit UNLOOP ELSE [ 1 CS-ROLL ] ... LOOP normal exit THEN ...
Of course. if the definition ends at THEN, you can simply do an early return
DO ... IF early exit UNLOOP EXIT THEN ... LOOP normal exit
Or if you just want to exit the loop and perform whatever code follows in all cases:
DO ... IF early exit LEAVE THEN ... LOOP all exits
Branching to a Common Start
This can be done using CS-PICK. The simplest example mimics the Java’s continue keyword:
BEGIN ... WHILE ... [ 0 CS-PICK ] REPEAT ... UNTIL
DO ... WHILE ...[ 0 CS-PICK ] REPEAT ... LOOP
may possibly compile too, but is not guaranteed to work, since do-sys may not be identical to dest. In this case, since the loop counter is decremented by LOOP rather than DO, each time the program hits REPEAT it effectively repeats the same iteration.
The same trick can be used within a CASE statement. Suppose you want the same action for a range of values, with one exception:
CASE
exception OF do-exception ENDOF
DUP range WITHIN IF DROP do-range ELSE [ 1 CS-ROLL ]
...
ENDCASE
THEN
On some (perhaps most) Forths this is unnecessary, since OF is the strict equivalent of OVER IF DROP and so can be paired with THEN, or IF paired with ENDOF.
Tuesday, September 20, 2005
EuroForth 2005
October 20th - 24th, Santander, Spain
The 21st conference for Forth and other extensible postfix languages,
virtual machine design, and stack based architectures.
Full conference details including a booking form may be found here
The 21st conference for Forth and other extensible postfix languages,
virtual machine design, and stack based architectures.
Full conference details including a booking form may be found here
Thursday, September 15, 2005
All the Standard Words
Somehow this puts me in mind of C K Ogden and his 850 words of Basic English...
Neal Bridges has produced a four-sheet reference for Standard Forth -- all 371 words with their respective Standard stack diagrams. It's in PDF format, and if printed '4-up' makes a pretty handy single-sheet reference (if a bit hard on the eyes).
I haven't seen this anywhere else in so compact a form. It's very useful for reminding yourself what words are in the Standard and how they are spelt.
Neal Bridges has produced a four-sheet reference for Standard Forth -- all 371 words with their respective Standard stack diagrams. It's in PDF format, and if printed '4-up' makes a pretty handy single-sheet reference (if a bit hard on the eyes).
I haven't seen this anywhere else in so compact a form. It's very useful for reminding yourself what words are in the Standard and how they are spelt.
Subscribe to:
Posts (Atom)