T < x < B

Too long to tweet, too short to blog.
Oct 08
Permalink

Function/constructor duality

  • <cdleary-lappy> Waldo: what's the canonical way of detecting whether you're being called from a constructor?
  • <Waldo> um
  • <cdleary-lappy> s/from a/as a
  • <Waldo> cdleary-lappy: what's regexp_call do?
  • <Waldo> (it calls a common helper as I recall)
  • <cdleary-lappy> I meant in JS itself -- is there an idiom for that?
  • <Waldo> you can't
  • <Waldo> you can sometimes know you *weren't* called that way
  • <Waldo> but even then not always
  • <cdleary-lappy> what's the "not always" case?
  • <cdleary-lappy> (probably a discussion for #jslang, but w/e)
  • <Waldo> function C() { if (!(this instanceof C)) throw "not new"; }; var c = new C; C.call(c);
  • <cdleary-lappy> ah, tricky
  • <Waldo> function C() { if (!(this instanceof C) || this.constructed) throw "not new"; Object.defineProperty(this, "constructed", { value: true }); }; var c = new C; C.call(c) /* *will* throw */;
  • <Waldo> that's the only hackaround I know
  • <cdleary-lappy> Waldo: seems like reasonable usage will work with the simple instanceof test, though
  • <Waldo> yes
  • <cdleary-lappy> constructing an invoking separately was something I wasn't even aware of! :-)
  • <Waldo> it takes some work to get this in one's head
  • <cdleary-lappy> what's annoying about it, though, is that you need the constructor binding hack to get arguments in the constructor after the check
  • <cdleary-lappy> eh, I guess not, you can just make the two forms expect different arguments form, but it's still quite ugly
May 06
Permalink
Go borrows a trick from BCPL: the semicolons that separate statements are in the formal grammar but are injected automatically, without lookahead, by the lexer at the end of any line that could be the end of a statement.
May 04
Permalink

ranlib ala #jsapi

  • * cdleary goes to find out wtf ranlib is
  • <jimb> cdleary: Yay!!
  • <jimb> something bad that the Unix guys thought was really neato
  • <Wes-> cdleary: jim's answer not withstanding, on older unices, you had to "ranlib" your .a files (archives of object files) so that symbols within the library, but outside of objects could be resolved by the linker whether their definition appeared before or after first use in the library. At least, that's what my memory tells me. I was pretty green the last time I ran ranlib and it was actually...
  • <Wes-> ...*necessary*
  • <jimb> cdleary: Originally, 'ar' was a general purpose file-archiving program whose format just happened to be understood by the linker. But its use for anything but libraries gradually faded away.
  • <jimb> And, originally, the .o files had to appear in the .a file in an order such that undefined symbols from earlier .o files would be resolved by later .o files, so the linker only needed to make a single pass through the .a file.
  • <timeless_mbp> technically ar is still used by debian archives :)
  • <jimb> I'm down with having simple tools that you use everywhere, but I'd argue that with those ordering requirements, the *net* simplicity wasn't optimized.
  • <cdleary> ah interesting -- wasn't aware .a had an internal order
  • <jimb> Well, once you've ranlibbed something, the linker consults that, and there's no internal order required any more.
  • <jimb> Anyway, the GNU binutils did away with that, and just built the index in ar, and made the archive mutation operations keep it up to date. So it's never mattered on GNU.
May 03
Permalink
By meditating effectively on anything you cultivate a keen alertness, a sharp and healthy mind. This meditation is about the breath.
May 02
Permalink
Many young girls define their self-worth according to how liked they are by others. They also equate success with being liked. Failure, or even constructive criticism, leaves many girls feeling as if they’ve personally let someone down, or that a relationship is damaged. Failure can feel personal and global, raising the stakes for a risk.
Apr 27
Permalink
Here, we try to speak clearly and in the simplest language possible because many of the people who read this forum are not as well-versed in these topics as we are, and many of whom would like to learn more.
Apr 26
Permalink
If you want to provoke discussion, logic and detail are not your friends. Instead, don’t worry about loose ends and half-expressed ideas - just keep the audience’s interest and provide colour, and let them fill in the gaps later.
Apr 18
Permalink
All enums implicitly extend java.lang.Enum. Since Java does not support multiple inheritance, an enum cannot extend anything else
Apr 09
Permalink

Building the V8 shell on x64:

set GCC_VERSION=44 scons arch=x64; g++ -Iinclude samples/shell.cc -o v8 libv8.a -lpthread
Apr 07
Permalink
It can only be avoided by using a separate terminal for program output which will be the case when we move to GDB/MI after the release. The only advice I can give you is “Don’t do that.”.
Apr 04
Permalink
Now the situation is more like the case where doSomething() was a final method in Foo — the compiler can convert the virtual method call into a direct dispatch (already an improvement) and, further, has the option to inline doSomething(), as well. (Converting a virtual method call to a direct method call is called monomorphic call transformation.)
Mar 24
Permalink
Generics were introduced in Java in Java 5.0 to allow type-safe generic programming. Unlike arrays, generic classes are neither covariant nor contravariant. For example, neither List nor List is a subtype of the other:
Mar 23
Permalink
Creating diagrams or pictures can allow you to connect ideas together on paper. Instead of having linear notes, organized in a hierarchy, what if you had notes that showed the relationships between all the ideas you were learning?
Mar 09
Permalink
Veneers are small sections of code generated by the linker and inserted into your program. armlink must generate veneers when a branch involves a destination beyond the branching range of the current state.