Thursday, May 01, 2014
The laptop computer is not to be used as a serving tray.
- From
- The Office Manager of the Ft. Lauderdale Office of the Corporation
- To
- The Ft. Lauderdale Office of the Corporation
- Subject
- Seating Arrangements for Today 5/1
- Date
- Thu, May 01, 2014 10:11 -0500
Hello Everyone,
Just an FYI today in regards to seating arrangements; our space is limited, so I have made the following changes for today:
- XXXXXXX Seattle guests are set up/sitting in the Manhattan Conference Room
- The Apollo Conference Room is for meetings only, please check calendar for availability
- XXXXXXX Florida employees—please have lunch in the QA area or Sean Conner’s office, if the Apollo Conference Room is not free
- The Apollo Conference Room is reserved
I wouldn't mind so much, but I find the excessive levels of mastication distracting.
Sunday, May 04, 2014
May the Fourth
Even though “Star Wars” premiered on May 25th (1977), Star Wars Day is apparently, for some odd reason, today. I don't quite understand why.
But to help celebrate the day, Bunny made my friends and me a cake.
And in case you can't make it out exactly, it is one of these:
May the force be—oh wait a second!
Monday, May 12, 2014
The Five Dollar Milkshake
That's a pretty XXXXXXX good milkshake. I don't know if it's worth five dollars but it's pretty XXXXXXX good.
Vincent Vega (“Pulp Fiction”)
It's not a five dollar shake, but nine dollars. It's not Jack Rabbit Slim's, but the Flashback Diner. And it still doesn't have bourbon.
And my god is it big. That sucker is about 9″ across and about that tall. I'm not sure if it was worth nine dollars, but it was pretty XXXXXXX good.
Tuesday, May 13, 2014
The laptop computer is still not a serving tray
Two weeks ago, my office was the temporary lunch room. Now, the lunch room is my temporary office.
The Ft. Lauderdale Office of the Corporation is expanding into the space next door. Because of that, an existing wall needs to be removed, and a non-existing wall needs to be constructed. Both walls simultaneously exist (currently separating the two spaces) and not-exist (to separate my office from the space next door) in my office. Thus, I am sitting in the conference room/lunch room for the forseeable future.
I've grown accustomed to the excessive levels of mastication though.
Wednesday, May 14, 2014
If we built ships like we built software—oh wait a second
Even though I'm a programmer, I can certainly relate to these 17th century ship builders (link via Flutterby).
Friday, May 16, 2014
A failed programming experiment
I have a Lua module that embeds a C compiler (and there's an extension module that allows you to load a Lua module straight from C code) which allows you to embed C code inside Lua code and compile it directly into memory:
cc = require "org.conman.cc" load = cc.compile('load',[[ #include <lua.h> int load(lua_State *L) { double load[3]; getloadavg(laod,3); lua_pushnumber(L,load[0]); lua_pushnumber(L,load[1]); lua_pushnumber(L,load[2]); return 3; } ]]) print(load())
I use it as a means to quickly test Lua functions in C without having to muck about with external files, C compilers and linkers. For that, it's wonderful except …
Errors. If there's an error in the C portion, I get:
[spc]lucy:/tmp>lua load.lua tcc: <string>:7: error: 'laod' undeclared
Yeah, the line number is correct as far as it goes—it's in line 7 of the code, but the actual line number is 10 of the file. Okay, in this case, I can do a simple search on “laod” but for instance, this error:
[spc]lucy:/tmp>lua load.lua tcc: <string>:10: error: ';' expected (got "lua_pushnumber")
It's actually line 12 of the file.
A recent message to the Lua mailing list reminded me that it is, indeed, possible, to get what I want from the output:
[spc]lucy:/tmp>lua load.lua tcc: load.lua:12: error: ';' expected (got "lua_pushnumber")
and that's by using the #line
C preprocessor directive.
It's a relatively straightforward matter to add such a line in Lua—just
generate a proper #line
directive and concatenate the code to
it before feeding it to the compiler. Getting the line information from Lua
is, again, straightforward:
static const char *itcc_add_line_info(lua_State *L,int idx) { lua_Debug info; /*------------------------------------------------------ ; get caller info and return linenumber and source file ;-------------------------------------------------------*/ lua_getstack(L,3,&info); lua_getinfo(L,"lS",&info); /*----------------------------------------------------------------------- ; line number will be negative if it's a Lua function written in C or if ; the source can't be located. If that's the case just return the ; original string, otherwise, prepend a #line directive and return the ; modified string. ;------------------------------------------------------------------------*/ if (info.currentline > 0) { char lineinfo[FILENAME_MAX + 32]; size_t len = snprintf( lineinfo, sizeof(lineinfo), "#line %d \"%s\"\n", info.currentline, info.short_src ); lua_pushlstring(L,lineinfo,len); lua_pushvalue(L,idx); lua_concat(L,2); return lua_tostring(L,-1); } else return lua_tostring(L,idx); }
Add the call to that function in the right spot, and voilà, you now have an uncle named Robert.
As I was coding this up and testing it, I realized something else—I don't always include the code as a literal to the function. Sometimes, I declare the code as a variable:
cc = require "org.conman.cc" LOAD = [[ #include <lua.h> int load(lua_State *L) { double load[3]; getloadavg(load,3); lua_pushnumber(L,load[0]); lua_pushnumber(L,load[1]) lua_pushnumber(L,load[2]); return 3; } ]] load = cc.compile('load',LOAD) print(load())
I do this when the C code is longer, or I have additional parameters to
pass to cc.compile()
. And in this case, the line number
reported will be the call site (for the above example, line 18) instead of
the actual error (line 12).
Well … darn.
It wasn't as easy as I thought it would be.
Tuesday, May 27, 2014
Musical Offices
Two weeks later and the lunch room is no longer my office (nor is my office the lunch room). It's nice to be back in my old office at The Ft. Lauderdale Office of the Corporation.
But I was told not to get too attached to my current office. Nope. Real Soon Now™ I am to be moved to a new office, just down the hall. Perhaps a day … perhaps two weeks.
On the plus side, I'll still have a window. Granted, the window has a wonderful view of the Ft. Lauderdale Office interior, but it's still a “window” office and it's not like it's any different from my current-soon-to-be-ex office.