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: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
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: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
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: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
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: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf

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: configure.ac and Makefile.am. 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 configure.ac, be prepared to really duke it out with Makefile.am. The final version of Makefile.am 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 Makefile.am 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.

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

These three lines build the 'libplisp.so' 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 Makefile.am.

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 autogen.sh 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 configure.ac and/or Makefile.am

3. You need to store configure.ac, Makefile.am, 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 Shaadi.com, Makaan.com 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)))))

Monday, November 17, 2014

pLisp FAQ

What is pLisp?
pLisp is an integrated Lisp development environment.

What dialect of Lisp is pLisp based on?

pLisp is not based on any single Lisp dialect, but draws inspiration from Scheme. However, its macro system is based on Common Lisp (backquote, comma and comma-at).

What features does pLisp support?

1. Basic operators like CAR, CDR, and other language primitives
2. Other operators and utility functions written in pLisp itself
3. Exception handling in the form of '(try .. (catch ..) ..)'
4. Garbage collection
5. Foreign function interface
6. Ability to store and load images (both at the system level and at the level of individual objects)
7. Macros
8. Debugger (break, resume, inspect variables)
9. A package/namespace system
10. Continuations
11. A basic but complete object system that supports inheritance, encapsulation, etc.
12. Graphical IDE

Why do we need yet another Lisp system?
pLisp started out as a hobby project, an implementation of an interpreter embodying the concepts in Paul Graham's "Roots of Lisp". As its feature-set kept growing, my dissatisfaction with existing Lisp development systems and my missing the beauty, power and elegance of Smalltalk environments in these systems prompted me to make pLisp more than just a command-line interpreter and add features like a system browser, workspace, and other good stuff.

My current objective with pLisp is for it to serve as a) a friendly Lisp environment for beginners and b) an end-to-end demonstration of the construction of a Lisp-based programming language system from scratch (object system design, virtual machines and intermediate code generation, garbage collection, serialization, just-in-time compilation, exceptions/continuations, and so on). And also serve as my personal programming environment, of course.

What platforms is pLisp available on?
pLisp is right now Linux-only. I may port it to other platforms in the future.

What about the license?
pLisp is licensed under GPL v3.

How do I install pLisp?
pLisp is installed by running 'make' on the provided make file.

What do I need to install pLisp?
You will need a) the GTK+3.0 development package (libgtk-3-dev) b) the Tiny C Compiler development files (libtcc.h and libtcc.a) and c) libffi

pLisp also uses Emin Martinian's Red Black Tree code in its GC implementation (this code is shipped along with pLisp, so you don't have to go out and grab it).

How do I report bugs and other issues?

You can email me at rajesh dot jayaprakash @ gmail dot com

Where is the documentation?
A user manual is in the works. I have some blog posts that talk about pLisp internals. I may expand these posts into a developers' manual in the future.

Friday, November 14, 2014

pLisp Updates

Thought I'd share some updates related to pLisp.
  1. pLisp has been migrated completely to Linux. I was already doing this in a half-assed way by using Cygwin, but faced issues with migrating to GTK 3.0, so a move to Linux made sense. I also wanted to make it completely portable, but one look at the horror that is autoconf/automake made me beat a quick retreat.
  2. I have been working on native code compilation, and it's been a partial success. Most of a closure/macro's code (the assembly Lisp that was being generated for the VM's consumption) is now native, except for the FRAME instruction. This instruction is problematic mainly because of the need to handle continuations. We need to maintain the calling stack even when we're doing native code, so the reliance on the present 'instruction set' (reg_accumulator, reg_current_stack, et al) is still there, making going full-native still some way off. I guess I need to grok Appel's Compiling With Continuations before I can do this. The Tiny C Compiler is used for the native code compilation; we dynamically create function pointers by converting the Lisp assembly code to C and invoking the TCC API to convert the C code to native code.
  3. Command line options have been introduced. Now you can run pLisp in console mode (-c), invoke it with an image (-i) or use it to just evaluate a single expression and quit (-e).
  4. A user manual and FAQ are in the works. I'm also looking for a new descriptive title ("pLisp is a Lisp-1 interpreter" doesn't really do it justice; since the UI draws a lot of inspiration from Smalltalk, maybe I'll change it to "Don't Lisp. Talk". Provocative much?)

Friday, October 17, 2014

October 17, 2014

You're not really a powerful country if you have to indulge in ridiculous-sounding trash talk like "Today, no one can give warning (sic) to India. We are a very powerful country".

The new Chief Economic Adviser's earlier connections with the Peterson Institute (of the "Social Security is for slackers" fame) do not bode well for what passes for the public safety net in India. Channeling provident fund money into the stock market is not a Good Idea.

Thursday, September 25, 2014

September 25, 2014

Holy Newspeak, Batman.

You wake up in the morning, feeling groggy, and make your way to the kitchen, where your better half has thoughtfully kept an inviting pitthalai tumbler and dabara of Kumbakonam filter coffee made from decoction brewed fresh just this morning. You take the coffee and head over to the front doorstep and pick up the The Hindu (could it be anymore South Indian? I could make it so, but let's not digress). You park your South Indian butt on the couch, mutter an expletive at the ad (real-estate, natch) that the folks at The Hindu have whored out their front page for and start reading the news, while at the same time taking the first sip of hot coffee.

And spit out the housefly that somehow made it into your coffee when you weren't looking, and continue the stream of expletives triggered by the first-page ad.

Alright, I made this up (the decoction and the pitthalai bits are true though, and I do read The Hindu every morning) but nothing compares better to the reaction I had on reading excerpts from Obama's speech linked to above. As someone who weaned himself away from the mainstream news a long time ago, I shouldn't really be surprised, but the chutzpah still hits you hard.
Russia’s actions in Ukraine challenge this post-war order. Here are the facts. After the people of Ukraine mobilized popular protests and calls for reform, their corrupt President fled. Against the will of the government in Kiev, Crimea was annexed. Russia poured arms into Eastern Ukraine, fueling violent separatists and a conflict that has killed thousands. When a civilian airliner was shot down from areas that these proxies controlled, they refused to allow access to the crash for days. When Ukraine started to reassert control over its territory, Russia gave up the pretense of merely supporting the separatists, and moved troops across the border. 
This is a vision of the world in which might makes right – a world in which one nation’s borders can be redrawn by another, and civilized people are not allowed to recover the remains of their loved ones because of the truth that might be revealed. America stands for something different. We believe that right makes might – that bigger nations should not be able to bully smaller ones; that people should be able to choose their own future.
 Far more articulate and better-informed folks on the internet will give this the reply that it deserves. I will stick to what I do best, i.e. writing dodgy haikus.

Crimea secedes?
Bad. What about Kosovo?
That's different, folks.

Voentorg for brothers?
Sorry, we frown on these too.
Syria? Not same.

Russians invade? Where?
Can't tell you. What? Don't trust us?
'K, here's a twitpic.

Buk Buk Buk Buk Buk Buk Buk.
Read the RUE report.

Links courtesy of The Saker and Dmitry Orlov. Also check out Mish's posts on Ukraine. 

Wednesday, August 27, 2014

August 27, 2014

I have become a fan of Game of Thrones, after recently getting myself one of those newfangled gadgets that everyone has been raving about -- what are they called again, let me think... yeah got it, tablets -- and discovering Show Box, one of those newfangled programs that everyone has also been raving about (apps, I think they're called).

The level of violence in the show is simply appalling, not to mention gratuitous, but the more important thing is how soon we're able to simply tune it out. Case in point (spoiler alert): Season 3, Episode 9: Caitlin Stark's throat gets slit end-to-end, and all you can think of is Does blood really flow in such a laminar fashion? Wonder how they mimicked the gurgling sound...

The show starts off in a gripping manner, up to and including the siege of King's Landing, but then sort of degenerates into a typical soap opera where your continued interest is on account of the familiarity with the characters rather than the plot itself. Things are not helped with the basic premise of the show being "The only rule of GoT is Valar morghulis", aka "Every character that you like will die a violent and/or undeserved death".

Speaking of characters I like, Tyrion is my favourite. His character has just been arrested for (spoiler alert) poisoning Joffrey, so I'll have to wait and see if he escapes execution. Wouldn't bet on it though. Another character whom you start out hating but then change your mind is Jaime. He's already been maimed, so I guess the odds on his surviving are somewhat better.

I know it's fiction and all that, but it's still a reflection of how badly life must have sucked in medieval times -- the palace intrigues, the back-stabbings and the betrayals people (at least the royalty) must have put up with, not to mention all the gory ways people were dispatched to their Maker during war.

The whole north-of-the-wall thing is more or less a sideshow at present, and a distraction at that. In my opinion, GoT is better off as an out-and-out medieval drama than as medieval drama + horror fiction. Let Cowboys and Aliens be the lord of the Mixed-Genre-F***up.

What's the most cringe-inducing thing in the world? Bollywood celebrities doing the ice bucket challenge for a disease that probably 0.0000001% of Indians suffer from. I have a better idea for a fundraising plan: allow folks to pee on you for 50 bucks (premium option: for 500 bucks you can do Number 2). Please deduct 25% from the charge if you just want to fling the pee/poo from a container instead. Containers available for a small fee.