October 2010
1 post
Function/constructor duality
Waldo: what's the canonical way of detecting whether you're being called from a constructor?
um
s/from a/as a
cdleary-lappy: what's regexp_call do?
(it calls a common helper as I recall)
I meant in JS itself -- is there an idiom for that?
you can't
you can sometimes know you *weren't* called that way
but even then not always
what's the "not always" case?
(probably a discussion for #jslang, but w/e)
function C() { if (!(this instanceof C)) throw "not new"; }; var c = new C; C.call(c);
ah, tricky
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 */;
that's the only hackaround I know
Waldo: seems like reasonable usage will work with the simple instanceof test, though
yes
constructing an invoking separately was something I wasn't even aware of! :-)
it takes some work to get this in one's head
what's annoying about it, though, is that you need the constructor binding hack to get arguments in the constructor after the check
eh, I guess not, you can just make the two forms expect different arguments form, but it's still quite ugly
May 2010
4 posts
Go borrows a trick from BCPL: the semicolons that separate statements are in the...
– Language Design FAQ
ranlib ala #jsapi
* cdleary goes to find out wtf ranlib is
cdleary: Yay!!
something bad that the Unix guys thought was really neato
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...
...*necessary*
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.
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.
technically ar is still used by debian archives :)
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.
ah interesting -- wasn't aware .a had an internal order
Well, once you've ranlibbed something, the linker consults that, and there's no internal order required any more.
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.
By meditating effectively on anything you cultivate a keen alertness, a sharp...
– Mindfulness of Breathing
Many young girls define their self-worth according to how liked they are by...
– Startups: An “Alpha Male Pissing-Contest?” | Fast Company
April 2010
6 posts
Here, we try to speak clearly and in the simplest language possible because many...
– http://lists.freebsd.org/pipermail/freebsd-performance/2003-June/000326.html
If you want to provoke discussion, logic and detail are not your friends....
– Wikibollocks: The Shirky Rules - Whimsley
All enums implicitly extend java.lang.Enum. Since Java does not support multiple...
– Enum Types (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Building the V8 shell on x64:
set GCC_VERSION=44 scons arch=x64; g++ -Iinclude samples/shell.cc -o v8 libv8.a -lpthread
It can only be avoided by using a separate terminal for program output which...
– Re: error in process filter: gdb-starting: Unexpected `starting’ annotat
Now the situation is more like the case where doSomething() was a final method...
– Java theory and practice: Dynamic compilation and performance measurement
March 2010
5 posts
Generics were introduced in Java in Java 5.0 to allow type-safe generic...
– Covariance and contravariance (computer science) - Wikipedia, the free encyclopedia
Creating diagrams or pictures can allow you to connect ideas together on paper....
– How I Was Able to Ace Exams Without Studying | Zen Habits
Veneers are small sections of code generated by the linker and inserted into...
– ARM Information Center
As the code matures over time, the development repository gathers a number of...
– MqExtension - Mercurial
Fortunately, the Java Platform provides a solution for that case by calling the...
– Interrupting Java threads
February 2010
18 posts
I like the font 13px/1.6em ‘Lucida Grande’,Lucida,Verdana,sans-serif
This idiom is sometimes summarized with the phrase “fork off and die
– Daemon (computer software) - Wikipedia, the free encyclopedia
Examples in this article are created using the AT&T assembly syntax used in...
– X86 Assembly/GAS Syntax - Wikibooks, collection of open-content textbooks
The C standard states that, after any parameters have been replaced with their...
– Macro Expansion - The GNU C Preprocessor Internals
C’s offsetof() macro is an ANSI C library feature found in stddef.h. It...
– offsetof - Wikipedia, the free encyclopedia
The drawback is that upon interactions with the system the registers need to be...
– SPARC V8 Stacks, Register Windows, and Procedure Call Conventions
There exist counterexamples to this, but in general, great things are...
– nomo zilla
The tool set includes sample simulators ranging from a fast functional simulator...
– What is SimpleScalar
Bunch is correct that the secondary purpose of copyright is to reward creators...
– Contextualizing the copyright debate: reward vs. creativity
Exception management is one of the main contributors to design complexity and...
– Energy-Exposed Instruction Sets
We provide provide two types of load instruction, one that checks cache tags and...
– Energy-Exposed Instruction Sets
The long startup time on a memory to memory machine is a function of memory...
– 3.5.1 Vector Processors
When the markup overhead exceeds 200%, when attributes values and element...
– S-exp vs XML, by Erik Naggum
Design collaboration is good, but design responsibility needs a home and it must...
– Design View / Andy Rutledge - Where the Buck Stops
Relying too much on proof distracts you from the real mission—which is...
– Seth’s Blog: Too much data leads to not enough belief
The theory of cognitive dissonance proposes that people have a motivational...
– Cognitive dissonance - Wikipedia, the free encyclopedia
Are you a serial idea-starting person? If so, what can you change to end that...
– Seth’s Blog: Random rules for ideas worth spreading
The goal shouldn’t be to have a lot of people to yell at, the goal...
– Seth’s Blog: Bullhorns are overrated
Picking the right text editor will not make you a better writer. Writing will...
– Mark Pilgrim on The Setup
January 2010
17 posts
It makes some sense to copy C syntax when you have to read C header files. It is...
– GCC to merge Go support [LWN.net]
You can change them, including by applying not only O(N), but also O(K)...
– Dr. Dobb’s | Break Amdahl’s Law! | January 17, 2008
[T]his approach becomes complex for callers, who instead of calling one function...
– Prefer Futures to Baked-In “Async APIs” | Dr. Dobb’s and Intel Go Parallel Programming
Any parameter we pass to add would have to be a subtype of this unknown type....
– Wildcards (The Java™ Tutorials > Bonus > Generics)
For many, “programming” has become a strange combination of...
– What Should We Teach New Software Developers? Why? | January 2010 | Communications of the ACM
Remember, when it comes to morale events, cheap beats infrequent every time. Big...
– I. M. Wright’s “Hard Code” : One to one and many to many
To add to hoang’s comment, after this was implemented by EDG, there was a...
– Deprecating export considered for ISO C++0x « Sutter’s Mill
A common myth is that each CAS operation “goes on the bus”, and,...
– David Dice’s Weblog : Weblog
A POD type in C++ is defined as either a scalar type or a POD class. POD class...
– Plain old data structures - Wikipedia, the free encyclopedia
ISO C99 supports compound literals. A compound literal looks like a cast...
– Compound Literals - Using the GNU Compiler Collection (GCC)
In ISO C99 you can give the elements in any order, specifying the array indices...
– Designated Inits - Using the GNU Compiler Collection (GCC)
In order for the dynamic_cast operation, the typeid operator or exceptions to...
– Run-time type information - Wikipedia, the free encyclopedia
One little-known usage pattern of the C preprocessor is known as...
– C preprocessor - Wikipedia, the free encyclopedia
Multiple-statement macro safety →
Nice reminder of the reason you should prefer do/while(0) macros: it’s all about the single-statement if/else construct with a semicolon!
# The network is reliable.
# Latency is zero.
# Bandwidth is infinite.
# The...
– Fallacies of Distributed Computing - Wikipedia, the free encyclopedia