Sunday, October 16, 2016

The BS Economy

Yesterday I got my aging tablet's screen protector changed. What should have been simple and quick visit to a mobile phone outlet turned out to be not so simple after all; I had to visit four such places before I could get this done. At each of the first three outlets, the response was that such services were not done there.

All of these outlets are located in a mall, one of the so-called trendier and happening ones in the city. You know how things are with malls: a lot of people strolling about, crowds at places like food courts and theatres, and most of the empty shops filled with bored salespeople with nothing to do but entertain themselves with fantasies of how they would like to push the strolling folks over the walkway rails.

The key word here is 'salespeople'; people who are trained to sell the stuff (I'm being quite generous with the word 'training' here), and nothing else.

There is a lot of talk about value-creation, moving up the value chain and so on, but this doesn't seem to translate very well into practice. We still have college graduates being churned out in their thousands every year, with degrees that are worth less than the paper they're printed on, with no real skills (and no, 'I have excellent communication skills and am a team player' is not a skill, even allowing for the invariable resume embellishment). The three or four years--don't get me started on engineering degrees--spent on getting a degree would have been much better spent in acquiring real skills like learning how to fix a car, cook a mean baingan bharta, or build a cabinet for a home entertainment system.

Or change the screen protector for a tablet.

Friday, September 09, 2016

September 9, 2016

Yeah, that about describes him perfectly:
If there was a fortune to be made at the bottom of a sack of shit, Blair would dive in head first (having been given a helpful push by his wife).
I have written about this before, but it's time to remind folks that there is another side to the story, in light of all the clueless people at the letters to the editor section at The Hindu who insist on rhapsodising about her sainthood:
What the hell, might as well throw this and this in as well.
Here's a pro-tip for the web developers working on the payment gateway module of our venerated public sector utilities (BSNL, if I'm not mistaken): when your message to the payment gateway is acknowledged to have been processed successfully, your response should be a matter-of-fact 'Yup, got it'. You should not display a 'Congratulations! Your payment has been processed successfully!' message to the user, conveying the impression that everyone at the backend were keeping their fingers crossed, and let out a collective sigh of relief that things worked out well after all. Doesn't inspire much confidence, folks.

Wednesday, August 31, 2016

August 31, 2016

Quick pLisp update: pLisp is now much more liberal with respect to symbol names: almost any character is acceptable, except for ten or so 'special' ones like backquote, comma, double quotes, and so on. This has resulted in the added benefit of doing away with things like LET1 and CALL-CC and going with the more standard LET* and CALL/CC.  Also, built-in functions like + and CAR can now be used wherever user-defined functions can be used, e. g., as arguments to APPLY and FUNCALL. This was achieved by creating user-defined wrapper functions for the built-ins; profiling indicates that there isn't much of a performance hit because of this additional indirection.

Monday, July 18, 2016

July 18, 2016

Well, the Turkey coup has fizzled out. I was initially rooting for it to succeed, but the ramifications would have been worse if it had, at least globally, and Erdogan's recent peace overtures to Russia would have been undone. But spare a thought for the poor soldiers: you are ordered to take your tanks to the streets, probably being told it's just a drill, you encounter protesters on the streets who, well, protest, and you hold your fire in spite of the provocations; realizing the true situation, you surrender to the civilians, and end up suffering indignities such as getting beaten up, or, even worse, lynched. And, if you haven't been lynched, probably facing a death sentence anyway.

Pop quiz: how do you put together, in a span of 24 hours, a list of 2700 or so judges who were involved in the coup attempt? Answer: You don't, you simply pull out the list of dissidents you had put together in the preceding weeks and months and use the Allah-given opportunity to get rid of them.

The Hindu chimes is as usual with its hemming and hawing. My late father--and others of his generation--had a colourful Tamil phrase, vazha vazha kozha koza (wishy washy), to describe The Hindu. The paper is still living up to this deserved reputation.

Speaking of The Hindu's opinions, I've always been at a loss as to how best to characterize this, notwithstanding the above apt phrase. Then it hit me: Grand Maester Pycelle in The Game of Thrones. Picture Pycelle speaking the words from The Hindu's editorials in his querulous and quavering voice, with liberal usage of "On the one hand..." and "On the other hand...", and you'll see what I mean.

It was bound to happen, and it did. The lemmings are at it again, this time it's Pokemon Go. The craze in the west is understandable, sort of: kids who grew up with Pokemon in the 90s are now young adults with disposable incomes, and Pokemon Go is a way for them to reconnect with the past. What's the lemmings' excuse?

Friday, July 01, 2016

July 1, 2016

Must-watch interview of Mark Blyth. You know we as a species are fscked when a video like this has only 12,534 views while Gangnam Style exposes overflow problems in the hits counter variable. The money shot (even better to hear it from the man himself, with his charming--Scottish?--accent):
...It's not going to sustain itself. So, you know the Germans have this thing that we don't want it to become a transfer union. What do you think you're in? Right? At the end of the day, you're transferring labour, skills, responsibilities, it goes with the gig. And you did an undervalued exchange rate by having your super-efficient economy buried in all these less-efficient economies so that you can sell more BMWs to the Chinese.
And this has relevance to what I mentioned yesterday about allowing malls to be open 24 hours a day (as in, this is the argument you should be using, and not the dishonest and cynical stuff):
Here's the problem: What do you mean by reforms? Some abstract notion that you should get into the pharmacy monopoly. Let's fuck pharmacists. I can now buy my meds over the counter in a supermarket which got deregulated hours so it's cheaper so we can all buy drugs at ten o'clock at night. Please tell me how that invigorates an economy that has lost 30% of its GDP. This is a fantasy.

Thursday, June 30, 2016

June 30, 2016

(Warning: Game of Thrones Season 6 spoilers)

Well, Season 6 of Game of Thrones is over. This is easily the best season so far for me, notwithstanding the WTFs involving Arya's Braavos escapades and Dany's crappy plot line. To be fair, I watched seasons 1 to 4 in more or less binge mode (bless you and RIP, Show Box), so I may be wrong. The post-premiere discussion megathreads at reddit are the place to be after watching the episode, where you get to experience the depth of emotions people exhibit for having R+L = J confirmed for them after waiting for 20 years and also some hilarious comments ("Lancel should have crawled zig zag" and "Tommen took the name 'Kings Landing' too literally").

Episodes like "Battle of the Bastards" and "Winds of Winter" are always better appreciated on the second viewing; half of the first time is spent in nervousness/dread, wondering what unexpectedly crappy thing is going to happen next. The second time you're more relaxed, knowing what's coming next, and are also on the lookout for the minor but important details you missed the first time (pointed out helpfully in the relevant reddit thread).

On a related note, I started watching The Walking Dead, and after two episodes I can't for the life of me figure out why it's held in such high regard; bad acting, bad editing, cliches all over the place, you name it. Maybe GoT has spoiled me, but things better start looking up in the next episode or two.

"Family life" my ass:
CAIT national president B.C.Bhartia and Praveen Khandelwal maintained that allowing shops and establishments freedom to operate on a 24/7 basis would have a detrimental impact on the traders. Their case is that it would have repercussions on law & order, environment, health, social and family issues.
Why not be upfront about the real reason, i.e., "Our business and profits will be at risk if this act is passed"?


pLisp has been ported to 64 bit. I thought I had already taken care of potential 64 bit issues, but boy was I wrong. The things that bite you in the ass are not the obvious gotchas like unsigned ints that were used to hold pointer values, but stupid effing stuff like missing function prototypes which screw you over in oh so unexpected ways. Nah, I'm not bitter at all, why do you ask?

Tuesday, May 10, 2016

May 10, 2016

In case you wanted any more proof of the way the markets are decoupled from fundamentals and are dependent (*ahem* coupled) on happenings elsewhere:
Sentiment was supported by lower-than-expected U.S. April non-farm payroll numbers, as it meant the Fed would take longer time [sic] to raise interest rates.
That's right, there's bad news on the economic front in the US, so their central bank is going to defer the rate hike, so it's good news for the Indian stock market because it's good news for the American stock market because of the continued maintenance of higher liquidity conditions there. Or, is it that the rate hike deferral means that emerging markets continue to be attractive to overseas investors? I don't know man, by now I don't know whether I'm coming or going.

Saturday, April 30, 2016

April 30, 2016

After a lot of false starts, I managed to port pLisp to Windows. Long story short, it took the MinGW GTK+ and GTKSourceview packages and the MinGW compiler--in Cygwin--to get things to work. The Windows version is shipped pre-compiled (for 32 bit right now); you just need to unzip the files to a directory of your choice (in addition to installing the aforementioned MinGW bundles).

Since we have all the bases covered (POSIX and Windows), pLisp has now been formally introduced to the rest of the world. Some very useful feedback and bug reports from the r/lisp community, thanks folks.

Monday, April 04, 2016

April 4, 2016

Excerpt from the Indian angle to the Panama Papers:
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at:
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.

Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at:
You really have to hand it to the 1%, the response is a masterclass in staying on the right side of truth while projecting an air of innocence (assuming they're not brazening it out on the assumption that nothing will come of the whole thing). "...I did not set up any offshore company" (doesn't preclude a registered agent setting it up for her), "...have no connection with Stanbridge Company" (again doesn't preclude having had a connection) and "It belongs to Mr V P Ahuja" (conveniently doesn't say whom it had belonged to).

Related must-read article. Also this, from 2014.

Staying on the subject of leaks, this is sure to bury the Unaoil leak. By the way, did you know that L&T was a beneficiary of a rigged tender process, courtesy of a Unaoil insider?
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at:
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at:

Thursday, March 31, 2016

pLisp File Browser

pLisp now has a File Browser too, for those who are not so enamoured with image-based development:

It's pretty much bare-bones functional; you can open, edit and save files (it's multi-tabbed, so simultaneous handling of multiple files is supported). The programming-specific features are the bells and whistles that are carried over from the Workspace: evaluating expressions, syntax highlighting, autocomplete, parens-matching, and context-sensitive help both via the F1 key and displaying function signatures in the status bar.

Friday, February 12, 2016

February 12, 2015

I think the government must be really desperate regarding the prospects of our economy to propose something like this. Use the money set aside for a rainy day (provident /prɒvɪd(ə)nt/ adjective - making or indicative of timely preparation for the future) and use it to, I don't know, buy a smartphone just so that demand picks up and the stock market starts rising again and the the folks with disposable incomes which go into SIPs can continue to breathe easy that their futures are secure (note that such folks will know better than to forgo their provident fund contributions and spend the money on useless junk instead).
 What's happening @Twitter? We wouldn't be talking about this or arguing about Facebook's Free Basics if the same efforts towards coming up with vendor-agnostic standards like HTTP, FTP, etc. could have been devoted to social media and Web 2.0 (rinses mouth out with Listerine). Imagine a world where you can use any protocol-compliant software (or even the browser itself) to do all the sundry things people do (follow/like/poke/stalk) on Facebook and Twitter, without being beholden to evil companies?
Before taking Headley's statements too seriously, people need to remember that he's completely owned by the Americans, and he will say whatever it takes to fulfill their foreign policy objectives (stoke up more conflict between India and Pakistan, bail out the Indian/Gujarat governments in the Ishrat Jahan case, and so on). Not to mention the annoying thing called 'hearsay'.

Thursday, February 04, 2016

February 4, 2016

Weather forecast for Chennai in The Hindu from a couple of days ago (italics mine):
Light winds are expected. A partly cloudy sky over the district. A cheerful morning. A delightful afternoon. An easy night.
In this time of 'Make in India' and the focus on local employment generation, it is highly condemnable that The Hindu have outsourced their weather forecast production to crumpet-eating, tea-drinking, monocled gents enjoying the pleasant English summer at Blandings Castle. Harrumph.

Sunday, January 31, 2016

January 31, 2015

Well, the bulk of the pLisp development work is done, except for maybe pushing GC to its own thread. Guess I'll start writing about the full monty compiler bits. By the way, I had mentioned earlier that pLisp ought to work on Cygwin, but it looks like the Tiny C Compiler is yet to be successfully ported to Cygwin, so running pLisp under Windows is a non-starter for the time being.

Monday, December 21, 2015

pLisp Migrated to Autotools Framework

I take back the bad things I've said about autotools. My second shot at making pLisp portable was successful; if not fully in the portability aspects, at least in making it conform to the whole configure/make/make install paradigm (ironic really, since my main objective was to port pLisp to Windows, which has not been achieved yet. Well, it should work for Cygwin anyway).

There is a lot of material out there on autotools, but most of them are outdated or handle only trivial Hello World programs. As with life in general, you need to do your homework to separate the wheat from the chaff and to dig out information that's really relevant to you. David A Wheeler's Howto was the most useful one for me.

At the risk of this post turning into yet another autotools tutorial that adds to the noise, here are some general guidelines and tricks while using autotools (I'll be using pLisp as a case study):

First off, you need to handcraft two files: and The first file tells autotools various things about your project like the package name, version number, which tools (GCC, flex, bison, etc.) it uses, what package dependencies does it have, and so on. You will not spend much time with this file once you put in all this information (actually, there's one gotcha: when mentioning package dependencies, I had to do them for each package separately [a la PKG_CHECK_MODULES([gtk], [gtk+-3.0 >= 3.4.2])]; for some reason, using DEPS_CFLAGS and DEPS_LIBS didn't work for me, and I had to build AM_CFLAGS and AM_LIBS from the individual variables as below:

AM_CFLAGS = ${gtk_CFLAGS} ${gtksourceview_CFLAGS} ${libffi_CFLAGS}
AM_LIBS = ${gtk_LIBS} ${gtksourceview_LIBS} ${libffi_LIBS} ${LEXLIB}


In contrast to the short amount of time you devoted to, be prepared to really duke it out with The final version of for pLisp is only about 40 lines long, but each of those lines has its own story of blood, sweat and tears.

The rest of this post will be in the form of inline comments interspersed with lines.

This line tells autotools that we want to include the -d flag in the call to bison. Needed because we want bison to generate a header file containing all the useful symbols like yyin, yyparse, and so on.

all:    ${bin_PROGRAMS} ${lib_LTLIBRARIES} help.html
This sets up the targets that need to be built: pLisp needs a binary as well as a library (.so) to be built, and also a language reference HTML, which is generated automatically from a JSON data file.

bin_PROGRAMS = plisp
plisp_SOURCES = ...

Here we list the binaries to be built, and for each binary specify the sources. Note that we simply list all the sources--including header files--and let autotools automatically take care of the dependencies. Extremely nifty feature.

noinst_PROGRAMS = docgen
docgen_SOURCES = tools/docgen.c src/util.c src/util.h src/json.h src/jsonlib.c src/json.l src/json_parser.y
The prefix 'noinst' indicates that these targets need to be built but not deployed. docgen is one such internal program; it generates the above-mentioned language reference HTML file, and it's work is done. Forever. The next line lists the sources needed to build docgen.

Since we're talking about source files, this is as good a place as any to say this: do not name your flex source files with a '.lex' extension; autotools will barf on them, i.e. refuse to invoke flex on them. The extension has to be '.l'.

AM_CFLAGS = -DDATADIR=\"$(pkgdatadir)\" ${gtk_CFLAGS} ${gtksourceview_CFLAGS} ${libffi_CFLAGS}
AM_LIBS = ${gtk_LIBS} ${gtksourceview_LIBS} ${libffi_LIBS} ${LEXLIB}

These two lines set the preprocessor and linker flags at the global level. You can also set them at a per-target level, like plisp_CFLAGS = ...

ACLOCAL_AMFLAGS = -I m4 --install
I really don't know much about this line, except that it is required to make use of the m4 directory (courtesy the Wheeler tutorial referred above).

plisp_LDADD = ${AM_LIBS} -ltcc
This line sets the libraries needed for the plisp binary; in addition to the global libraries, we also specify the Tiny C Compiler library. Required because tcc doesn't follow the pkg-config framework.

libplisp_la_SOURCES = src/plisp_utils_ffi.c
libplisp_la_LDFLAGS = -version-info 0:0:0

These three lines build the '' shared library. That's the extent of my knowledge of the matter, my lord.

pkgdata_DATA = data/plisp.lang data/help.json lib/plisp_full_monty_compiler.lisp
dist_doc_DATA = doc/help.html doc/pLisp_User_Manual.pdf
iconsdir = $(pkgdatadir)/icons
icons_DATA  = icons/abort.png ...

Now this is where the power of autotools really shines through: pLisp, like any application worth its salt, has a bunch of resources that are needed for correct operation. These resources range from the plisp.lang file needed by GtkSourceView to do syntax colouring to the PGN files needed for the icons in the application toolbars. These four lines take care of generating the makefile commands that copy these resources from their respective locations in the source directory hierarchy to the user-specified directory (when she runs './configure') without us or the source code being aware of any of these shenanigans. Truly magical. Hyperbole aside, how this is accomplished is much more mundane: if you look at the AM_CFLAGS definition above, you'll notice the -DDATADIR flag; this flag is set to the package data directory (typically /usr/local/share/plisp), and is used in the source code [e.g. gtk_image_new_from_file(DATADIR "/icons/load_file.png")] to abstract away the location of the resource file.

src/json.c:    src/json.l
    $(LEX) --prefix=json -o src/json.c src/json.l
src/json_parser.c:    src/json_parser.y
    $(YACC) -d -v --name-prefix=json src/json_parser.y -o src/json_parser.c

And that brings us to the primary reason for all the blood, sweat and tears alluded to above: the inability to handle multiple lexers/parsers within the same program. pLisp uses flex/bison for two things: a) to parse the Lisp source code entered by the user (or fed from a file) and b) to parse the JSON strings used for representing both pLisp images and the online help content. When I was using a handcrafted makefile, I could keep the flex/bison symbols (yyin, yylval,  yyparse) separate by using different name prefixes in the individual makefile rules. The only way to get the same behaviour in autotools seems to be to specify the same rules manually. Goes against the philosophy, but there doesn't seem to be any other way to do this.

help.html:    docgen

This use of a manual rule is justified, since this is an application-specific thing to generate the online help file.

And we're done with

Some odds and ends:

1. You will need to create a bunch of dummy files at the project root: AUTHORS, NEWS, COPYING, ChangeLog, etc. Also create a directory called 'm4' with a dummy file in it (e.g. NOTES, as suggested in the Wheeler tutorial).

2. Create a script called with just a single line 'autoreconf --install || exit 1' in the project root as well, and run this script to process any changes you've made to and/or

3. You need to store,, and the files mentioned in #1 and #2 above in your version control system.

Tuesday, December 15, 2015

December 15, 2015

Random thoughts on the recent Chennai rains:
  1. Let's get the unpleasant stuff out of the way first: notwithstanding all the talk about Singara Chennai, there is a reason (well, reasons, to be more accurate) that the phrase 'third-world shithole' keeps getting thrown around when it comes to Chennai in particular and India in general. Overcrowding, lack of public hygiene and civic sense, corruption, unregulated and illegal growth, you name it. All this is business as usual, but when something like a once-in-a-hundred-years flood occurs, the rottenness of the system is there for all to see. There are folks who still harbour love for the city in their hearts, of course, but there are two aspects to this: one is the affection and familiarity one feels towards their favourite childhood haunts, the neighbourhood they grew up in, and so on, while the other pertains to the truly beautiful things the city is known for. The first is operative mainly because of the strong sense of nostalgia that glosses over all the squalid bits, while we're fast running out of things in the second category (if you are a regular reader of S. Muthiah's column in The Hindu, you can't help but notice that said beautiful things were all the creation of people who left us at least thirty to fifty years ago).

  2. People will be people. In particular, good people who feel sympathy for others' suffering will help them, while not-so-good people will try to take advantage of others' misery. You therefore have folks wading through waist-deep water, risking their own safety to reach out to people who need help, and also those who take this opportunity to loot homes abandoned because of the flooding, and who jack up their auto fares to take advantage of people's predicament (on a related note, the most apt icon/mascot for Singara Chennai would be a snarling autorickshaw driver). While the outpouring of goodwill during the crisis was indeed admirable, expect good old reversion-to-the-mean to kick in shortly, if it hasn't already. By the way, there are Facebook stories doing the rounds in which one hears that motorists' driving behaviour has become more patient and courteous; these are either made-up crap like the Chickenshit for the Soul stories, or are one-off anecdotes.

  3. At long last I found some use for social media. Nothing like Twitter to bring to you instantaneous pictures of the flooding around your locality and thereby saving you from an injudicious route choice. Newspapers were practically worthless (if you manage to get hold of them, that is), with their lagging-by-eight-to-twelve-hour coverage. Even their Twitter feeds were not as useful as citizen-journalists', probably because of their need to curate what they put out.

  4. If I were made dictator, one of my first acts would be to can the entire meteorological department and replace it with two things: a) a subscription to the high-fidelity Accuweather satellite data and b) a Python script that does ARIMA. Enough said. Oh, by the way, that Ramanan guy is definitely trolling everybody (vittu vittu mazai peyyum, sila idangalil mazai peyyum).

  5. Some practical advice for what to do if you're caught in such a situation in the future (notwithstanding the tendency to attribute all such extreme weather conditions to global climate change, I think it's unlikely that this will recur in the next five years):
    1. Always keep at least Rs 5000 in cash with you in the house. Cash is king in such times. Also, rotate the money every six months. You never know when the government will get serious about black money and declare that all old currency notes--especially 500 rupee notes--are no longer legal tender.
    2. Wean yourself from milk. Unless you're a baby, of course. People complaining about no milk during these times makes me shake my head. You can always stock milk powder.
    3. Potatoes and onions don't need refrigeration. In general, keep a stock of provisions to last you at least a week. And don't forget batteries. Lots of them.
    4. This is a bit of an overkill, but battery-operated amateur radio is a great way to communicate when the cell towers give out.
    5. When you still have your wits/senses about you, make a list of important stuff to take with you when you need to evacuate. Otherwise you will end up carrying out worthless stuff like, I don't know, dosai maavu, while leaving behind a pile of black money for the looters to find when they come calling (true story).
    6.  Make a hard copy of all the important phone numbers in your address book and keep it in your wallet. You never know when you might need to call somebody from another person's phone because yours ran out of juice.
    7. And last but not the least, learn swimming.

Monday, November 30, 2015

November 30, 2015

A quick update about pLisp: the full monty compiler is done, I'm in the process of updating the documentation (online help [i.e. within pLisp instead of taking the user to the language reference HTML] and autocomplete). I am also tempted to add a 'references' feature which will show the list of all the code that refers to a particular top-level symbol; this is not to difficult to implement, though there may be some false positives because of lexical variables with the same name).

Thursday, October 22, 2015

October 22, 2015

From John Michael Greer's latest Retropia installment (italics mine):
It was an interesting ride, in an odd way. I travel a lot, like most people in my line of work, and I’ve ridden top-of-the-line automated light rail systems in New Beijing and Brasilia. I could tell at a glance that the streetcar I was on cost a small fraction of the money that went into those high-end systems, but the ride was just as comfortable and nearly as fast. There were two employees of the streetcar system on board, a driver and a conductor, and I wondered how much of the labor cost was offset by the lower price of the hardware.
Leaving aside the argument of whether automation and technological advances are going to lead to large-scale unemployment, I'm going to focus on more practical things -- namely, traffic signals. There is a signal at an intersection on my daily commute that's not been working for, I don't know, at least a couple of years (its work is being done by its smaller sibling that is barely visible among the various obstructions that the Chennai road landscape is known for, but that's another story). The most likely reason for this organizational apathy and, possibly, lack of funds. Now things are only going to become worse from here on, with the global economy marching firmly down the deflationary path, and purse strings are unlikely to be loosened locally either, once we too are caught up in the downward spiral.

Well, what was my point? Lost sight of it there for a moment. My point is that technological solutions, automation, and in general the whole smart/intelligent movement will not solve our problems, especially in a country like India where the environment is harsh and hostile to equipment like traffic signals and other electrical equipment open to the elements (leave alone sophisticated things like automatic urinal flushes that detect that you're done with your tinkling and flush away the output of said tinkling [I've always been wary of these things; what if, due to a bit flip caused by a speck of dust in the wrong place, it decides to reverse the flow and dump on me the aggregated output from the previous four users of the system?]). In such an environment, it makes more sense to put warm bodies to work; in the case of traffic signals, this means having policemen direct the traffic manually (and intelligently to boot, using their own grey matter; I know that algorithms have shown how effective they are at achieving, ahem, globally optimal outcomes, but it's not an all-or-nothing thing; nothing precludes an intelligent program running in the protected environs of a climate-controlled data center from passing on advice to the policeman on the ground using, I don't know, a smartphone app. Note to self: fix appointment with $CLUELESS_GREEDY_VC to pitch idea for hot new traffic management startup).

Pop quiz: what's wrong with the following paragraph?
Although India was secularized at the official level, religion remained a strong force at the popular level. After 1990 some political leaders tried to benefit from popular attachment to religion by espousing support for programs and policies that appealed to the religiously inclined. Such efforts were opposed by most of the state elite, who believed that secularism was an essential principle of Nehruvian Ideology. This disinclination to appreciate religious values and beliefs gradually led to a polarization of society. The polarization became especially evident in the 2010s as a new generation of educated but religiously motivated local leaders emerged to challenge the dominance of the secularized political elite.
Well nothing in and of itself, except that I created it from another paragraph (hat tip to Mish) by replacing exactly four words (two proper nouns and two numbers). As Redditors would say, mildly interesting.

Wednesday, September 30, 2015

September 30, 2015

The report Sergey Glazyev prepared for the Russian Security Council (it's leaked text and purportedly contains deliberate injections of falsehoods, so take it with a pinch of salt). Expands on the interview I had mentioned earlier. Serious brain food. I have a good mind to put together the tables in Appendix 5 for India.

A pity the content at The Saker has become more and more diluted, with original analysis by Saker in what, one out of every twenty posts. Makes one miss out on stuff like the 'War on Syria: Not According to Plan' series by Ghassan Kadi. Mandatory reading for anyone who wants to go beyond the usual lame analysis (he could have avoided the use of 'NWO'  to talk about the post-1991 period, and also gone easier on the pro-Assad bits, but good stuff nonetheless).

Monday, August 31, 2015

Full Monty Compiler for pLisp -- Part 1: Overview

Before diving into the different phases of the compiler, it would be helpful to set out our overall goals and the context which the compilation process fits in.

Our guiding principles are:
  1. Retain as much of the current code base as possible
  2. Use the same object model, core library, grammar and primitives as currently exist in pLisp
  3. All top-level forms are to be compiled to native code (i.e. even simple, ad hoc expressions like (+ 1 1))
  4. Our goal (at least for now) is correctness and completeness; some of the code transformations are not optimal, but we're willing to go with them in the interests of keeping things simple
 As the compilation process moves through the different phases, we end up with simpler and simpler dialects of Lisp:

Not every transformation results in a new dialect; for example, both the input and output of the renaming transformation are in the 'pLisp_IL' dialect.

Onto the grammars for these sundry pLisp dialects (I'm skipping pLisp in the interests of laziness, except to say that it's pLisp_k + macros):

1. pLisp_k

The 'k' stands for 'kernel', as in the core language we're left with once all the macros have been expanded/desugared.

exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (set var exp)
    | (let exp* exp)
    | (letrec exp* exp)

literal ::= integer | float | symbol | nil | t | character | string

variable ::= <check plisp.lex for the rule(s) defining variables>

primop ::= ' | atom | eq | cons | car | cdr | + | -

| * | / | progn| print | listp | symbol_value
| ` | > | gensym | setcar | setcdr | create-package
| in-pacakge | , | ,@ | expand-macro | apply
| string | make-array | array-get | array-set
| sub-array | array-length| print-string | create-image
| load-foreign-library | call-foreign-function | load-file
| consp | integerp | floatp | characterp | symbolp
| stringp| arrayp | closurep | macrop | continuationp
| format | clone | return| return-from | symbol
| symbol-name | unbind | newline | time | profile
| not | &lt; | &lt;= | >= | != | save-object | load-object
| export-package | env | eval 

2. pLisp_k_no_set

pLisp_k_no_set is identical to pLisp_k, except that there is no 'set' form:

exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (let exp* exp)
    | (letrec exp* exp)

(primops omitted from here on for clarity)

3. pLisp_IL

pLisp_IL ('IL' stands for Intermediate Language) differs from pLisp_k in two ways:
  1. There is no 'letrec' form
  2. A new construct 'let1' that desugars to 'let'. Functionally 'let1' is identical to Common Lisp's 'let*', but since our parser doesn't handle '*', we go with 'let1'.
exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (let exp* exp)

    | (let1 exp* exp)

4. pLisp_IL_CPS

pLisp_IL_CPS is the continuation-passing version of pLisp. I'll explain this in more detail when I talk about CPS conversion; for now, note two important constraints: a) 'let' forms will have only one binding and b) there are also restrictions on what can be 'lettable' expressions.

exp ::= (var val*)
    | (if val exp exp)
    | (let ((var le) exp))
    | (error exp)
    | (call-cc exp)

val ::= literal | var

le :: = literal | (lambda (var*) exp) | (primop val+)

5. pLisp_IL_Lift

pLisp_IL_Lift continues with the simplification further: the only forms permitted on the right hand sides of binding expressions in 'let' are variables, literals and primitive applications (also, the only permitted arguments to the primitive applications themselves are variables and literals).

exp ::= (var val*)
    | (if val exp exp)
    | (let ((var le) exp))
    | (error exp)
    | (call-cc exp)

val ::= literal | var

le :: = literal | (primop val+)

One form not included in these is 'define', used to create top-level forms. Strictly speaking, 'define' is handled outside the compilation process (though we need to call the compiler to compile and evaluate the expression whose computation should be mapped to the variable being defined).

Subsequent posts will talk in detail about the different phases.

Friday, July 31, 2015

Building a Lisp Interpreter from Scratch -- Part 14: Full Monty Compiler

Well, I finally got around to implementing a full monty compiler for pLisp. I say 'full monty' because this version attempts to completely do away with the interpreter; now an expression passed to the REPL will be compiled to a native function plus the objects that represent the free variables in the expression (aka a closure) and then executed.

I still haven't worked out all the wrinkles, specifically how to handle macros, but considering that macros are pretty much identical to regular functions (as evidenced by the identical interpreter code that handles both), this should not be too difficult.

The full monty compiler does its job in phases:
  1. Macro expansion
  2. Assignment conversion
  3. Translation to intermediate pLisp
  4. Renaming transformation
  5. Simplification of the intermediate pLisp
  6. CPS transformation
  7. Closure conversion transformation
  8. Lift transformation
Each of these phases is a separate post in itself, so I'll dive into them in the coming weeks. Discerning readers will notice that these phases seem to be incomplete (i.e. no register allocation, mucking around with type information, and so on). The reason for this is two-fold: a) we're not compiling to assembly or machine code, but are targeting C (letting the Tiny C Compiler handle things from this point onward), thereby obviating the need to dive into things like register allocation and b) pLisp is dynamically typed, with no attempt made to infer types and type correctness at compile-time.

Right now the compiler is written in pLisp itself (everybody raise your hands and say 'Code is Data'), and produces code in a Lisp dialect I've dubbed 'pLisp_IL_Lift', which is then executed by a toy interpreter in pLisp to verify the correctness of the compilation. The plan is to produce a hand-written version of this compiler in C and use this version (v1) during business-as-usual (one can even produce the C version of the compiler by running v1 on the compiler pLisp source to produce v2 -- we can then proudly proclaim that the pLisp compiler is written in pLisp itself, but let me not get ahead of myself).

P.S. Tip of the hat to Design Concepts in Programming Languages for nearly all of the underlying theory.

Monday, June 29, 2015

June 29. 2015

I don't really know how feasible "targeted multi-channel financing" is, but Glaziev makes a lot of good points in a candid manner ("Interviewer: It's that simple?" Glaziev: It's not simple at all").

It's a long read, but if you just had half an hour to spend on coming up to speed with the whole "what's wrong with the current global finance regime" (not to mention a primer on global finance and investment), spend it on this interview. A couple of choice bits: 
In other words, our monetary authorities are working for foreign speculators? What about the Western sanctions?
Not just foreign ones. Here as well the income of speculators grew like mushrooms sprouting up after rain after the ruble was allowed to float freely. They have superior communication and authoritative leadership with access to confidential information from the regulator. Creating “currency swings” – this latter created a real gold mine for them… By the way Western sanctions only affect loans with a term of over a month. They don’t apply to short-term loans, which are what the speculators depend on. Indeed they need loans for literally one day, often – for one hour. So the entire Western financial system is still connected to our financial market, which is still dominated by foreign speculators – they account for 90% of transactions...
And this isn’t a return to a planned economy?
If so, then Japan, China, India and Brazil all have planned economies. And even in Western Europe there was also a planned economy before the introduction of the Euro – money was printed by the national banks according to demand from the manufacturing enterprises, as confirmed by their business plans, the implementation of which was monitored by commercial banks. They took the risks of lending to their clients and refinanced with the national banks using promissory notes...
 The status quo will persist as long as the speculation-is-good-for-injecting-liquidity side prevails in the ideological debate. Regulatory capture and corruption/blackmail also help.
Maybe Greenpeace at the international level is different, but I have a very low opinion of their torch-bearers in India, even ignoring aspects related to their funding. What's the most attention-whory way to protest the freezing of your accounts? Let me see, oh, a couple of us will don mountain-climbing gear and unfurl our protest banners from the top of the building while dangling precariously. Is there an easier and safer way we can accomplish our objectives? Hush. A long time ago I attended a concert that was sponsored by Greenpeace, and there was this guy on the stage who went on and on about how he was hanging out in the Rainbow Warrior (that's their famous ship that keeps sailing around the world doing, well, attention-whory things ["it's all for the ENVIRONMENT, dammit!"]), how he had not yet decided whether to continue his voyage or pursue his fucking PhD, and so on. My interactions with the local volunteers over subsequent years lead me to believe that most of them are cut from the same cloth as that guy.

Thursday, June 25, 2015

June 25, 2015

(Warning: GoT spoilers)

Season 5 of Game of Thrones is over. It was an enjoyable season, especially the latter half. Something I started doing after watching the last three episodes was to head over to r/gameofthrones/ to catch up on the reactions to the episode in question. In fact, it wouldn't be inaccurate to say that r/gameofthrones/ was the only place I visited for about three days after the season finale. Entertaining stuff, reading about the speculations, fan theories, and so on (not to mention learning new things: did you know that R+L = J?). Quite a bit of the heartburn and pointless debates there can be avoided if folks kept two things in mind: a) HBO will do whatever it takes to make more money and b) as a reddit user so eloquently put it, "it's a show with fucking dragons". Fidelity to the book, what was going on through a character's mind when they did that thing, does something really make sense and so on are pretty pointless. Having said all this, here are my own speculations:
  1. Stannis the Mannis is gone.
  2. Hard to say about Jon (refer R+L=J above)
  3. Sansa and Theon survive
A word about the books: I have just started on the first one, and I must say that the writing is quite underwhelming (maybe things improve in the later volumes).

Speaking of spoilers, trust the pimps at ToI to trumpet out Jon's demise from the rooftops barely three days after the show, thereby spoiling it for countless fans who were late in catching up.

Monday, June 01, 2015

June 1, 2015

The Hindu is either trolling its readers or severely underestimating their reading comprehension skills. First this:
The Ambedkar-Periyar Study Circle (APSC) at the Indian Institute of Technology-Madras has been distributing pamphlets and posters that call for, among other things, removal of ‘brahminical tyranny’.
and in the same breath (italics in original):
But such an association will be spurious, as questioning orthodoxy and conservatism is not tantamount to hate speech, which is characterised by a deliberate targeting of communities rather than beliefs.
Now we know which god the BCCI folks look to for inspiration and pray to everyday.
Yet another spelling bee competition, yet another Indian-origin winner. A good language is one for which there are no spelling bee competitions. Dmitri Orlov's Unspell project is a step in the right direction, but its success remains to be seen.

Sunday, May 17, 2015

May 17, 2015

Colour me distinctly unsurprised. I have written about this earlier too; it all makes sense once you realize that the admissions process in Ivy League colleges in the U.S. is biased towards grooming the scions of the wealthy and connected to take up their station in life. Our own admissions systems, i.e. JEE and CAT are slowly getting there -- give them another decade or so, and we'll be right up there with the 'best' of them.

Thursday, April 30, 2015

April 30, 2015

A bit harsh, but you'll find specimens that arouse similar sentiments here too:
Take a couple of minutes to gaze at the face of Victoria Nuland, or Jan Psaki, or Samantha Power, or Hillary Clinton. Don't they all remind everyone—that is, us regular American guys of whatever ethnic origin—of that quintessential “cool crowd” we had to contend with during our student days? Aren't they all a bunch of uppity up-tight feminist radical liberal bitches who once made a living hell out of our fresh, green and naïve college days? Well, now that we are not so horny and stupid any more, and they are all wrinkly and saggy (or worked on and Botoxed to hell) don’t we all want to metaphorically get down on our knees and thank Jesus or Yahweh or Allah or whoever that we didn't end up marrying one of these specimens?
Whenever I think of feminism, I picture a differently-abled, fresh-out-of-high-school girl from an ultra-orthodox family in a South Indian village who moved with her younger, even naiver sister to another town to take up a job and made a success of it. Not these whatchamacallits.

Wednesday, March 25, 2015

March 25, 2015

It's different this time:
Anupam Mittal, founder of People Group, which owns Internet ventures like, and an early investor in Ola, agrees. “Of course valuations have skyrocketed in the last one month. Even for a start-up raising $1 million, it has now gone to $2-3 million. Valuations may look running ahead of fundamentals for Flipkart, Snapdeal or Ola. However, it will look justifiable in the coming 12 months given the growth rates these firms are witnessing,” he says.
“If you look at Fortune 500 companies, 50 per cent of valuations are given for intellectual property. The same holds true for Internet ventures. It is the network effect. One has to pick and choose the right winners in the game,” he says.
That, dear reader (I accidentally typed 'readr' and corrected myself, but come to think of it, that's more appropriate in this age of quikr, fukr, and the like), is called "talking one's book". Intellectual property my ass.

International venture capital, having run out of options back home, is seeking yield in the next bubble, namely Indian e-commerce sites with a shaky business model (it helps if you have a mangled name; see above. Oh, and you have to have a FREE app. Those of you without one, please show yourself out. Thanks for your time).

If you're the sort who's willing to invest as large a sum of money as goes into a real estate deal just because you can book your flat online (gasp!) or take a virtual tour of the property, I have this amazing deal for you... oh wait, never mind.

Want to buy diamonds online? Check. Eyeglasses? We've got you covered. Try out ten sets of dresses at home and just keep the one you like best? You got it (pity those poor Myntra delivery guys carrying half the store on their backs, though). What about furniture? You bet.

But jokes aside, this is what is called a win-win situation by the jargon-mongers. On the one side you have a) savvy shoppers looking for and getting great bargains b) slick home-grown would-be entrepreneurs cutting their teeth on hoodwinking gullible investors c) app developers d) newspapers getting revenues from full-front-page ads and e) even folks like the aforementioned overworked delivery persons, while on the other side you have... what? Greedy investors who know very well what they're getting into ("What is this "due diligence" thing I keep hearing about? And so what if the caviar is empty? There's always room service...")? No contest.

Tuesday, February 10, 2015

February 10, 2015

This is about the upper middle class in America, but the argument applies equally to their Indian counterparts. From tax deductions for home loans to subsidized cooking gas, it's "you'll have to pry it from my cold dead fingers" all the way. Not to mention that they've thrown their weight behind promises of more shiny new things they can buy (Ultra HD TV, anyone?) as the economy is being unshackled by the latest saviour (the AAP has basically wiped the floor with their opponents in Delhi as I type this, so maybe there is some hope left).

Wiser words have never been spoken (via xymphora):
Instead, in every domain, over and over, the policies that prevail are those with business-models. Policies that create a large pool of wealth for a small number of players, enough money in few enough hands that there’s some left over to lobby for the continuation of that policy.
I think that we’ve tacitly acknowledged this in policy circles for years – if you have something you think would be good for society, you need to figure out how it will make a small group of people rich, so they will fight to keep it going. It’s how we got carbon trading! And carbon trading is a great cautionary tale for activists thinking of harnessing policy business models to attain their objectives: the people you make rich will fight for a version of your policy that makes them as rich as possible, even if it means subverting the underlying social good that your policy is supposed to attain.
From yesterday's The Hindu, about three Indian cities being chosen for the 100 Resilient Cities project:
The financial commitment for the project is $100 million. This doesn’t mean each city gets $1 million. What the cities would get are funds to recruit the chief resilience officer. Other than that, support would be in the form of tools, people and the network.
One million dollars at current exchange rates translates to a salary of about Rs 50-60 lacs per year for two years (leaving the rest for administrative expenses), about enough time to attend about five to ten local and international soirees and hobnob with the movers and shakers, give an equal number of interviews to magazines and newspapers (whose editors you met during said soirees), and utilize the time in-between to type up a 500-page report (double-spaced, naturally), and still be left with a couple of months in which to polish your resume for your next gig. The word you're looking for is 'sinecure'. 'Bribery' if you don't want to mince words.

Staying with The Hindu, their International page devotes more column inches to cover the International Film Festival in Berlin than to report on the much more important happenings in Ukraine.

#9 and #10 in the list of Indian names released as part of the HSBC leak are the Ambani brothers. What lends credence to this, despite the protestations of innocence, is that the balances against their respective names are identical ($26, 654, 991). Indian Express is the Indian partner of the consortium who took part in this expose, so there is always the lingering doubt that it's a copy/paste error, but an equally plausible reason is that the amount probably works out to a nice round figure when converted to rupees. I'm too lazy to do the math, but this looks to be in the ballpark of Rs 100 crores at the time in question (2007).
Must-read articles about the recent AI-Skynet brouhaha (I discovered Wait But Why only recently, via RI; some seriously good brain food there). I have been fully inoculated by John Michael Greer against the whole "Rapture of the nerds" thing, so I'm compelled to ask: would an Artificial Super Intelligence be able to defy the laws of thermodynamics? Even so, some good stuff there.

Monday, January 05, 2015

January 5, 2015

(Reason #2534 why Lisp rules)

The Lisp assembly code generated by the compiler in pLisp is already in continuation-passing style, but I wanted to have a fresh look at the whole compilation process so that the current limitations related to compiling the FRAME instruction are overcome, and also wanted to correctly handle continuation objects in the full-native-code mode where we will not have reg_accumulator, reg_current_value_rib and the other machinery that the Lisp assembly depends on.

Time to hit the books; in particular, Appel's Compiling With Continuations.

We first compile the source code into continuation-passing style, apply closure conversion to this, and then do the remaining good stuff like elimination of nested scopes, register spilling, target assembly generation and so on.

In this post I'm just going to talk about the first step, i.e. conversion to CPS-style, as I've progressed only to Chapter 5 in the book so far. But even at this stage, the advantages of programming in Lisp stand out. More specifically, two features: a) 'Code is data' (I might as well print a T-shirt with this emblazoned in the front) and b) gensym (yeah, this is not exactly a universal Lisp feature, but the ability to create and manipulate symbol objects programmatically is, I guess). Oh, and since we're doing the entire thing in pLisp itself, a tip of the hat to the whole meta-circular interpreter thing; the ability to write and test out these things in Lisp itself is a godsend not only in terms of saving time, but is also central to leveraging the features mentioned above.

The CPS version of pLisp source code is a CONS object, the CAR of which is the expression to evaluate, and the CDR of which is a lambda expression to which the result of the evaluation is passed. Textbook CPS stuff. As an example,

((cons a b) <exp>)

is converted to

(cons (lambda (x) 
        (a (lambda (y) 
             (b (lambda (z) 
                  ((x y z) <exp>)

where <exp> is the rest of the computation (also a CPS expression) where our expression fits in.

To convert to and evaluate CPS expressions within the interpreter, we need an environment to map variables--both source expression variables and the lambda variables created as part of the conversion. A normal way to do this is to create an ASSOC-PAIR object and get and put stuff into it. But no, we do things the cool way (this is a nifty technique to mimic environments in interpreters):

(defun env0 (x)

(defun lookup (e var)
  (if (primop var)
    (e var)))

(defun update (e var val)
  (lambda (v)
    (if (eq var v)
      (e v))))

The environment is not a data object; it's a closure. We start out with an initial environment that simply returns NIL. When a new symbol is added to it, we produce a new closure that returns the value corresponding to this symbol if the argument matches the symbol, and defers to the original environment otherwise. Symbol lookup is just invoking the environment with the symbol (an added wrinkle is that we need to evaluate symbols corresponding to primitive operators to themselves). Brilliant, if you ask me.

Conversion to CPS-style is done by the to-cps function (from this point on, the code is in image form, apologies; click on the image to see it fully):

The function takes a source expression [e.g. (cons a b)] and a receiver CPS expression, and produces a CPS expression that is the receiver expression into which the converted source expression is embedded. An example:

(to-cps '(cons x (+ x x)) nil)

evaluates to:

(imagine that the LAMBDAs are preceded by a left paren as CONsing them with a symbol removes the left paren in print mode).

All the #:G symbols may look ugly, but if we're counting on GENSYM to generate symbols on the fly for us, we're going to have to live with them.

Evaluation of CPS expressions is done by eval-cps:

Since we're doing everything within the pLisp interpreter, and code is data, all we need to do for the actual evaluation is to invoke apply.

(eval-cps (to-cps '(cons x (+ x x))) (update env0 'x 100))


(100 . 200)

And voila, we've implemented Chapter 5 in less than 50 lines of Lisp code (arguably for a more elegant and powerful language). Less than 25 lines if you ignore eval-cps.

Wednesday, December 24, 2014

December 24, 2014

As Sheldon would say, "bazinga!" (emphasis mine):
It’s a tough decision to normalize relations with a country whose police force murders its own innocent civilians on almost a daily basis, and even more abroad, but Cuba needs to do it.

There's been a lot of hand-wringing and "what kind of people would do something like this" about the Peshawar massacre. 'Joe Hillshoist' at RI gets it right:

From what I understand a recent Pakistan Army offensive left between 500 and 2500 civilians dead in the border region where the Pakistan Taliban are based. I'm not justifying killing kids - what seems to have happened at Peshawar is horrific, like the 7 or 8 kids found stabbed, along with their mum, in a house in Cairns today. But you can't just single out one horrific act in a series of tit for tat horrific acts and pretend it signifies anything other than a horrible cycle of revenge. A cycle that needs more than one actor to perpetuate it. I'd like to think that if someone blew up my wife and child while I was at work I wouldn't want to retaliate like that but who knows really. I hope I never find out.

One bomb
The whole block gone
Can't find my children
And dust covers the sun
Everywhere is noise, panic
And confusion
But to some another fun day in Babylon
I'm going to bury my wife
And dig up my gun
My life is done
So now I'm going to kill someone...
This post is turning into a quote-fest, last one, I promise. This time from a letter to the editor in The Hindu (side note: the letters section in The Hindu is the place you go to to bone up on your collection of barely-appropriate figures of speech and metaphors [a sample from letters on the same day: eye-opener, take with a pinch of salt, hand-in-glove, pillar of support, riding on the plank of, nip the trouble in the bud, ...]) -- a rare voice of critical thinking:

The findings (that if the intelligence agencies of the UK, US and India had shared information and connected the dots, 26/11 could have been prevented) are striking, but one needs to take them with a pinch of salt. It is a fact that the U.S. still has not come clean on the role of David Headley. Or it could be that India knows the truth and has chosen not to pursue the matter keeping in mind the importance of economic interests. The West definitely knows a lot more about global plots and plans than it ever reveals. Wikileaks is a good example of doublespeak by the West.
(Yeah, I know, "pinch of salt", but still)
Question time: Do you remember the kiss you stole when she was standing under the mistletoe? Or the time you got a buzz from splurging on plum cakes? What about the time you went a-carolling late at night, with the snowflakes grazing your face as you stamped your feet and buried your hands deep into your jacket pockets to keep away the cold?

If you are a typical denizen of the tropical lands of India for whom all this Christmas revelry means is nothing more than a break from work and a disgusted shake of the head at the way the festival is being commercialized just to ring in a few more pieces of silver into the coffers of businesses, your answers to these questions would have been "No", "No", and  "Fuck no" respectively. The correct question to ask is "What the fuck is Coke doing with a half-page ad peddling its wares as a staple of Christmas revelers ("Plum cakes, bright lights / Mistletoes,carol nights / Christmas is about togetherness / With Coca-Cola (R), family and friends") in India?

Thursday, December 04, 2014

December 4, 2014

In a move that's bound to offend Lisp purists, I have added support for C-style arrays in pLisp; it is now possible to get and set array elements by syntax like a[10 2]. I initially thought of doing this the canonical way, i.e. a[10][2], but this complicates the lexical analysis (I have already introduced shift/reduce conflicts with these changes), so a single pair of square brackets will have to do.

You can thus do things like these now:

USER> (define a (array (2 2) 1))

[[1 1] [1 1]]

USER> a[0 0]

USER> (aset a[0 0] 100)

[[100 1] [1 1]]

array and aset are macros that internally call make-array and array-get/array-set respectively:

(defmacro array (dims default-value)
  (if (eq (length dims) 1)
      `(make-array ,(car dims) ,default-value)
    `(make-array ,(car dims) (array ,(cdr dims) ,default-value))))

(defmacro aset (ref val)
  (let ((a (second ref))
    (last-index (last ref))
    (indexes (butlast (cddr ref) 1)))
    `(array-set (build-ref ,a ,indexes) ,last-index ,val)))

During lexical analysis, the form a[x y] is converted into a list (aref x y) so that the sanctum sanctorum of the interpreter and other bits of pLisp are not polluted by the impurity of the square brackets.

build-ref is a macro that is used internally to convert a reference of the form (aref array-name i1 i2 ...) to one that uses array-get.

(defmacro build-ref (a indexes)
  (let ((rev-indexes (reverse indexes)))
    (if (eq (length rev-indexes) 1)
    `(array-get ,a ,(car rev-indexes))
      `(array-get (build-ref ,a ,(cdr rev-indexes)) ,(car rev-indexes)))))