2,513 reputation
411
bio website
location Illinois
age 44
visits member for 2 years, 5 months
seen 16 hours ago

Nov
3
comment How have languages influenced CPU design?
@MichaelT: The two answers are sufficiently disjoint that I think they should be voted upon separately. Although the 80486 absorbed the functions previously performed by the 8087/80287/80387, the 8086 and 8087 were designed as separate chips with nearly-independent architectures. Although both ran code from a common instruction stream, that was handled by having the 8086 treat certain byte sequences as requests to generate address read/write requests while ignoring the data bus, and having the 8087 ignore everything else that was going on.
Nov
3
answered How Byte loading/storing is implemented By the CPU?
Nov
3
comment How have languages influenced CPU design?
Reading the paper, it sounds like many aspects of the design could be useful in object-oriented frameworks such as are popular today. An architecture which used a combination of a 32-bit object-id and 32-bit offset could in many cases offer better caching performance than one where object ids were all 64 bits (in most cases, an application which would use billions of objects would be better served by instead having more, larger ones; one which would store billions of bytes in one object would be better served subdividing that into smaller objects.
Nov
3
comment How have languages influenced CPU design?
@MichaelT: I don't think so--one covers stack design, and the other covers floating-point semantics.
Nov
3
answered How have languages influenced CPU design?
Nov
3
comment Do any notable C extensions include integer types that are independent of machine word size
My question was not how to force the correct evaluation of one particular arithmetic expression (depending upon which kind of result one wants, either cast an operand to uint32_t or else use a macro defined as either #define UMUL1616to16(x,y)((uint16_t)((uint16_t)(x)*(uint16_t)(y))) or #define UMUL1616to16(x,y)((uint16_t)((uint32_t)(x)*(uint16_t)(y))) depending upon the size of int) but rather whether there are any emerging standards for how to handle such things usefully rather than defining my own macros.
Nov
3
answered Undefined behavior, in principle
Nov
3
comment Do any notable C extensions include integer types that are independent of machine word size
@delnan: Further, while something like (uint16_t)((uint32_t)ffff16*ffff16) would be a portable way of performing the math according to mod-65536 arithmetic (in case one was e.g. doing certain kinds of checksum calculations) I'd consider that really ugly; it makes it look as though code wants to perform a 32-bit computation, when what it really wants is simply to get a result whose bottom 16 bits are correct. On many smaller platforms, the latter could be achieved much more cheaply than the former, though compilers for such platforms may not optimize the code with the typecast.
Nov
3
comment Do any notable C extensions include integer types that are independent of machine word size
@delnan: Your understanding of the standard is probably the same as mine; I know that compilers are only supposed to define certain types if they behave according to the rules of two's-complement arithmetic, but I think that restriction only applies to e.g. int32_t rather than uint16_t; further, even if a compiler would require that (int32_t)((uint32_t)ffff16 * ffff16); would yield a two's-complement result, I don't think that implies that ffff16*ffff16 wouldn't be Undefined Behavior.
Nov
3
comment Do any notable C extensions include integer types that are independent of machine word size
...are as they are not because anybody tried to formulate a set of rules that "made sense", but rather because the Committee was trying to nail down all the things that the independently-written compilers that already existed had in common. Unfortunately, this approach has led to standards which are simultaneously too vague to allow programmers to specify what needs to be done, but too specific to allow compilers to "just do it".
Nov
3
comment Do any notable C extensions include integer types that are independent of machine word size
@RobertHarvey: One of the historical goals of the C Standards Committee has been to make it possible for almost any machine to have a "C compiler", and have the rules be specific enough that independently-developed C compilers for any particular target machine would be mostly interchangeable. This was complicated by the fact that people started writing C compilers for many machines before the standards were drafted, and the Standards Committee did not want to forbid compilers from doing anything that existing code might rely upon. Some rather fundamental aspects of the standard...
Nov
3
revised Do any notable C extensions include integer types that are independent of machine word size
added 3276 characters in body
Nov
2
asked Do any notable C extensions include integer types that are independent of machine word size
Oct
28
comment Is it permissible to use explicit interface implementation to hide members in C#?
@nikie: ...would be to have a base collection interface include a property that would return a reference to a CollectionAbilities object that would indicate which features were or were not supported [allowing much more detail than the poorly-named ICollection<T>.IsReadOnly], while allowing a typical implementation to simply define and return a singleton.
Oct
28
comment Is it permissible to use explicit interface implementation to hide members in C#?
@nikie: The collection interfaces are poorly designed but the idea of having members that may or may not be supported is perfectly sound. For example, if an object which receives a reference to an object from one piece of outside code, is supposed to expose some of its abilities to another piece of outside code, it should be usable with any object which can support all the methods the outside code requires. Defining interfaces to precisely fit every combination of IList<T> features that particular implementations would or would not support would probably take over a dozen; a better idea...
Oct
28
comment Is it permissible to use explicit interface implementation to hide members in C#?
Hiding may be entirely appropriate in situations where a class might implement an interface method in a fashion which complies with the interface contract but isn't useful. For example, while I dislike the idea of classes where IDisposable.Dispose does something but is given a different name like Close, I would consider it perfectly reasonable for a class whose contract expressly disclaims states that code may create and abandon instances without calling Dispose to use explicit interface implementation to define an IDisposable.Dispose method that does nothing.
Oct
28
comment Are Language Comparisons Meaningful?
It might be good to extend this somewhat by saying that while a screwdriver would be rather less effective than a claw hammer when pounding nails, that doesn't mean it's an "inferior" tool. Alas, people will often (metaphorically speaking) try to pound nails with a screwdriver and then condemn it as a piece of garbage; if told that screwdrivers only work well when used with screws rather than nails, they'll condemn the screw driver as being less effective at pounding screws than it had been at pounding nails. Even if screws would have fit their needs perfectly, they'd still be "garbage".
Oct
28
comment When to use identity comparison instead of equals?
Two more situations where == is appropriate are when an object (such as IdentityHashMap) has received objects from outside code which expects them to be compared with ==, or when a method acts upon two objects, at least one of which is received by outside code and the other of which has been exposed to outside code, and it needs to ensure that in fact has two distinct objects, rather than two references to the same one.
Oct
28
comment Representational Equality versus Value Equality
What makes references in Java and .NET in some ways most interesting, however, is that they are "unpronounceable". In C++, the bit patterns stored in a pointer could be considered a "name" which will be associated with the object until it is deleted. Such a bit pattern, like any other, could be displayed on a screen or typed on a keyboard. In Java and .NET, however, objects have no name which is guaranteed to exist from one moment to the next, save for the whereabouts of references to them--the aspect of state/identity mentioned in the previous comment.
Oct
28
comment Representational Equality versus Value Equality
An extremely important, but often overlooked, aspect of an object's state is the existence (and whereabouts) of things that identify it. If a reference to an object is stored as a key in an IdentityHashMap, adding information to the associated value will add it to the object's effective state. As a consequence, even though immutable objects should have no identity, all types of references in Java can be used to encapsulate identity whether the types in question want them to or not.