For those who don't know, the object in the image is a tram. Trams are great because they run on electricity and not gasoline so they produce much less pollution than for example cars.
And this is an image of a commuter train. Those trains are also great because they don't pollute.
What is not so great is that not enough people use these services. The highways are crammed with cars (often with only a single person in them) trying to get in our out of the city centers. Trams and trains are great, but cars are bad because they pollute a lot.
What is not so great is that it costs you about 120 SEK to make a round trip from Södertälje to Stockholm. It's 160 SEK if you are travelling from Gnesta. That is to expensive. It takes longer and is not much cheaper to travel to Stockholm by mass transit than by driving a car. So if you have a car then you will use that to commute if you aren't particularly concerned about the enviroment.
Previously, it costed 40 SEK for a round trip to and from Stockholm. That price was much more palatable and quite a few people decided to use the mass transit instead of driving. It was changed because the current politicians thought it was to expensive for the state, but it was not. SL could have easily affored it, but the politicans prioritised tax cuts instead of social service.
Mass transit should be free, and it should be funded by taxes. Everyone should have equal and cheap access to travel for commuting and so on. Making the mass transit free is the simplest and cheapest way to drastically reduce carbon dioxide emissions and improving quality of life.
This article is related to two patches to cairo, #12717 and #12722. Many times in C, you want values in a certain range, or some that are not above or below a certain value. The process which ensures that values are within a certain range is called clamping.
Let us say that you have function that sets the position of something.
Further assume that the position must be contained within obj:s clip rectangle. That could be accomplished using this code:
A mathematical way to write the clipping would be something like:
obj->x = x, obj->rect.x <= x <= obj->rect.x + obj->rect.width obj->y = y, obj->rect.y <= y <= obj->rect.y + obj->rect.height
Time to introduce the MIN and MAX functions and see how they can help us. In C, they can be implemented as macros.
It should not be any surprise that
is exactly equivalent. We can therefore rewrite the boundary checking code in set_pos to take advantage of these macros:
But wait, there is more! The code can be further rewritten if we introduce a CLAMP macro.
Now we can make the set_pos function even more readable:
Note how similar this code is to the imagined mathematical definition. It is also worth noting that the CLAMP macro doesn't work if the value of the upper bound is lower than the lower bound. That is, if obj->rect.width or obj->rect.height is negative, then the macro will give erroneous results.
Totally great, now developers finally are forced to fix their (null) strings they dump in output and in configuration files. Programs become more portable and developers learn the important lession of being careful with NULL, what's not to like about that? :)
I very much like the way the gcc developers are going even if their changes affects me too. They seem to fully realize that following specified standards is much more important than preserving backwards compatibility.
Remember, what doesn't kill you only makes you stronger!
- ► 2013 (15)
- ► 2012 (82)
- ► 2011 (23)
- ► 2010 (21)
- ► 2009 (25)
- ► 2008 (23)
- ▼ oktober (6)