Showing posts from July, 2007

Useful Regexp in Emacs for C++

First press Ctrl-Alt-Shift-5 to get Query-Regexp-Replace
Then I want to find C-style casts in my .cpp file, and replace them with C++ style casts. For example:
GeoData *gd = (GeoData *)mThreeDData;
GeoData *gd = dynamic_cast<GeoData *>(mThreeDData);

First I figure out that this: (\w+ ?\*)[A-Za-z_]+
will find the expression I want. It's finding the parens, then \w is a 'word-constituent' which fits our type names nicely, followed by an optional space and the * for pointer. But in variable names, we often use underscores, so I search for those explicitly.

Now I need to save parts of the search expression and use them in the replace expression. So I enclose in \( \), and reference with \N
The search becomes:
(\(\w+ ?\*\))\([A-Za-z_]+\)
and the replace becomes:

A case this doesn't handle is if the C-style cast was on a method or function call, or array reference.
(Outline *)annot_to_save[i]
dynamic_cast<Outline *>…

Locust in glass

This is the best picture my wife has taken. At the North Carolina Museum of Life and Science.

Humming bird nest

Lichen and spider webs. There is one egg in the nest.

Slaughterhouse Five

or The Children's Crusade
by Kurt Vonnegut, Jr.

The author writes about Billy Pilgrim, who becomes unstuck in time. He witnesses the firebombing of Dresden in WWII, and is kidnapped by aliens.

"If I hadn't spent so much time studying Earthlings," said the Tralfamadorian, "I wouldn't have any idea what was meant by 'free will.' I've visited thirty-one inhabited planets in the universe, and I have studied reports on a hundred more. Only on Earth is there any talk of free will."

A phrase used to connect deaths in the book:
So it goes.

Billy is disturbed, checks himself into an asylum, but his time-travel and display in the alien zoo are treated as obviously true. Because he is changing time-lines constantly, he is passive in everything that happens to him.

Kilgore Trout appears a sci-fi writer whose "prose was frightful. Only his ideas were good."

This book is a classic because it makes a lasting impression. I picked it up and read it agai…

The Sum of All Fears, by Tom Clancy

The Sum of All Fears
Author:Tom Clancy
ISBN-13: 9780425184226
ISBN-10: 0425184226
Book Type: Paperback

I stayed up late finishing it. Compelling read. The final note from Tom Clancy tells how worried and amazed he is that it would be relatively easy for a rich and secretive person to fabricate a hydrogen bomb, given some access to raw materials, as in the novel. Engrossing, entertaining, _and_ made me think - the best traits in a spy novel. I have not yet seen the movie.

My only objection: it's too long (~900 pages). It suffers with sub-plots that are developed and then thrown away after interacting briefly with the main story line. It all ties together, but some of the ties are to weak and coincidental to be interesting.

Info at PaperBackSwap