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.
Wednesday, August 31, 2016
Monday, July 18, 2016
July 18, 2016
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.
Friday, July 01, 2016
July 1, 2016
...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
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.
Why not be upfront about the real reason, i.e., "Our business and profits will be at risk if this act is passed"?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.
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
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
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
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.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
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…”
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
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?
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
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
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
Thursday, February 04, 2016
February 4, 2016
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
Monday, December 21, 2015
pLisp Migrated to Autotools Framework
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.
AM_YFLAGS = -d
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
./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
- 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).
- 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.
- 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.
- 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).
- 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):
- 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.
- 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.
- 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.
- This is a bit of an overkill, but battery-operated amateur radio is a great way to communicate when the cell towers give out.
- 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).
- 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.
- And last but not the least, learn swimming.
Monday, November 30, 2015
November 30, 2015
Thursday, October 22, 2015
October 22, 2015
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).
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.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.
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
Our guiding principles are:
- Retain as much of the current code base as possible
- Use the same object model, core library, grammar and primitives as currently exist in pLisp
- All top-level forms are to be compiled to native code (i.e. even simple, ad hoc expressions like (+ 1 1))
- 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
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 | < | <= | >= | != | 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:
- There is no 'letrec' form
- 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'.
| 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
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:
- Macro expansion
- Assignment conversion
- Translation to intermediate pLisp
- Renaming transformation
- Simplification of the intermediate pLisp
- CPS transformation
- Closure conversion transformation
- Lift transformation
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
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?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.
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...
Thursday, June 25, 2015
June 25, 2015
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:
- Stannis the Mannis is gone.
- Hard to say about Jon (refer R+L=J above)
- Sansa and Theon survive
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.


