Subj : Re: Pairs of 32-bit pointers To : netscape.public.mozilla.jseng From : "Sterling Bates" Date : Sat Dec 06 2003 09:40 pm "Brendan Eich" wrote in message news:3FD2AA5E.2030509@meer.net... > Sterling Bates wrote: > > >The first is storing the data type of a variable in the first pointer, with > >the variable's contents in the second. This would avoid modifying the > >actual variable (or pointer to it) itself. > > I have no idea what you mean here. Could you give an example? Some > context? A use-case? Thanks. I could compare it to argv, where argv[-1] points to "this" (or some such). Given two sequential pointers, the first 32 bits describe the type (and possibly the refcount as I saw some discussion about that), while the second 32 bits contain the value/pointer to the value of the variable. So booleans would be 0 or 1, integers would have their full range, etc. When passing a reference to the variable, you would pass a pointer to the second of the 32 bits. When checking the type of the variable, the program would access the previous four bytes of memory. > >The second is function callback. Delphi (and possibly C++, but I don't > >know) > > > > Not C++, unless you make a method pointer explicitly. Wish Delphi did that... > > stores two pointers for every object method: one to the code, and one > >to "this" or "self". By permitting a method pointer as a callback, > >developers could point directly to the object instance that expects the call > >instead of a call wrapper. The private slot is not always available, or > >sometimes just not a good idea, for this. > > It's not relevant. The private slot isn't relevant, or the concept? > > JSString, for instance, uses its > >private slot for its own data. This prevents a developer from using that > >slot for an external object reference. (Granted, that's likely a rare > >occurrence with JSStrings, but it highlights the point.) > > Hard cases make bad law. Usurping private to make a bound string method > reference is wrong. Use JSFUN_BOUND_METHOD and the parent slot. The docs (as accurate as they are ) indicate that the flag is deprecated. My reason for bringing up JSString is my inability to associate an instance of JSString (and jsdouble, for that matter) with a Delphi object wrapper. I referenced method binding for callbacks only, eg all JS*Op callbacks. I have to declare them as standalone functions/procedures which attempt to connect to an existing object instance in Delphi. It's just another step for code to walk through. Sorry for my original post's ambiguity :) Sterling .