101 karma · joined May 21, 2014
The pimpl idiom is a C idiom where a header declares an opaque structure and prototypes of functions that take pointers to that structure. In C the OP example would look something like
// widget.h
typedef struct Widget_t Widget; /* opaque! */
Widget* Widget_Create(const string* pName);
Widget* Widget_Clone(Widget*);
void Widget_Destroy(Widget*);
void Widget_click(Widget*);
int Widget_clickCount(const Widget*);
const string* Widget_label(const Widget*);
// widget.c
struct Widget_t {
int clicks;
string *name;
};
// ... implementations of the functions from the .h ...
In particular, in C `Widget` directly has `clicks` and `name` as fields.But in c++ we like to use methods on objects, and in order to do this, you need the class declaration in scope, which means your current compilation unit needs to have seen all of Widget's data members. In practice this means if you try to use "pimpl" in C++, you do something like the OP where there is a pointer to an opaque type inside your class.
However, this is not the same thing. Methods are called with a `this` pointer, which means every access to the internal structure adds a second pointer dereference. This is why this isn't the true pimpl -- it wastes an extra deref on every access.
You can get true pimpl in current C++ but it's a lot of boilerplate and heavily relies on compiler inlining. An implementation of the example from the OP: https://godbolt.org/z/6EznxeG1n . In practice this is too much work, hard to read, and so nobody does it.
For the c++ standards committee: please add an "opaque class" feature where the class can only define non-virtual method prototypes. Then the full class declaration, in the associated cpp file, could include its parent classes, actual data layout, and function implementations.
If everyone feels that way, then it's not an above-market rate, it's by definition the market rate. The market rate for a job might be different at different locations.
(Note that I'm not taking a position on whether or not using the H1B program to reduce the market rate here is a good idea)
https://www.copyright.gov/512/
Read the requirements for a takedown notice. The only thing a DMCA notice needs to claim under penalty of perjury is that you are authorized to enforce the copyright that you are claiming. The report from the copyright office on the linked page states:
> Senders of both takedown notices and counter-notices are liable for damages if they make knowing material misrepresentations regarding whether the material to be taken down is infringing, or has been removed or disabled by mistake or misidentification. Courts have appropriately interpreted this provision by requiring actual knowledge or willful blindness of falsity, not merely negligent or unreasonable misrepresentation.
"Knowing" does a lot of heavy lifting here. Courts have determined that someone who uses an automated system to identify infringing content and submits takedown notices against all of that content does not "knowingly" misrepresent anything.
Furthermore, even in the case where there is bad faith, there's no statutory penalty, it relies on the targeted party suing and in court proving BOTH bad faith, and damages.
The DMCA has no teeth against false claims.
1 2 |x x |
if I left click the second cell and drag right it should mark all the blank cells black.Similarly in the inverted case, if I have marked cells and right-click-and-drag next to them it should mark the empty spots I cross over with Xs.
Important: this doesn't change the state of any cell that wasn't blank to start out. You should have to click on a marked cell to clear it (or right click to replace it with an X). And similarly to above, if you drag, it should change only the cells you touch that match the starting state of your original cell to the new state.
Let's say that some new use for copper is discovered, that drastically increases the demand for copper. The cost of existing items that use copper is going to go up, even if those items are no more productive than they used to be, because the new items are now in high demand.
You can see this effect in real life with GPUs; it's much more expensive to buy a gaming graphics card today than it was a decade ago, because GPUs are in high demand for other applications.
So, increasing the productivity of labor in some sector is going to do the same thing supply and demand does to anything else -- the cost of labor goes up, but not as much as the productivity in that sector, and the producers of labor will enjoy higher demand.
It's not like any individual reform is going to suddenly end all that waste and put everyone involved out of a job. Iterative small improvements make a real difference in people's lives, and won't provoke an immediate giant supply-side shock.
I don't pretend to have the answers to the question of "what reforms should we do?" but throwing our hands up and saying "nothing!" is not the answer.
function weightedRandom(weight, outcomes){
var total = sum( weight );
var roll = Math.random()*total; // value in the range [0,total)
var seen = 0;
for(let i=0; i<weight.length; i++) {
seen += weight[i];
if(roll<seen)
return outcomes[i];
}
}Wikipedia cites sources. Go to those sources, find the ones that best line up with the data you need, and cite them directly.
Treat Wikipedia like an aggregator -- you wouldn't cite an HN post, you'd cite the link it pointed at.
To counteract this negative feedback loop, assuming the increased prices don't drive away all of your real customers, you can spend the increase on transaction analysis, and turn away customers based on their likelihood of fraud, so you've added inefficiency into the system to help deal with a criminal element, and also likely turned away real sales due to false positives in your analysis.
It's no surprise that these types of merchants are looking for a disruptive technology to remove this inefficiency. Doing so would allow them to charge less and outcompete as well as capture the entire market of people marked as false positives by other merchants.
EASTL provided a bunch of value that the standard STL would not. The biggest benefit was a unified implementation across all platforms. Standard library STLs all had their own idiosyncrasies and code that worked on one platform might not compile, or worse, have a bug on another.
At the time, EASTL was equal or higher quality than standard implementations. Performance was better, code quality was better, and it broke from the standard in some key ways that were important for performance, and it had some key upgrades that allowed usage patterns and data structures that the standard STL simply didn't allow:
Vectors supported "trivial relocation" before the existence of move constructors. While move constructors have ameliorated the problem, I argue that feature is still missing from c++. Please support P1144! http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1144r5....
Intrusive containers (in particular, intrusive linked lists in eastl::intrusive_list) embed the container overhead into objects themselves. This allows non-movable objects to be stored in these lists without requiring an extra pointer dereference on access. It also lets you convert an object reference into an iterator over the list that contains it. There are tons of uses for this. It also allows polymorphic lists (e.g. intrusive_list<BaseClass> that actually holds instances of various subclasses, again without an extra pointer dereference)
If you want more information, EASTL's lead programmer Paul Pedriana (rip) goes into detail in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n227...
That said, they definitely had problems with failing to culturally assimilate immigrants during the late empire -- when "citizens" of the empire didn't think of themselves as Roman but instead primarily part of some other group.
It's clearly an industry with huge potential if it is economically viable to spend money buying an Argentina's worth of power on it.
Here is the exact text from the DMCA from https://www.aclu.org/other/text-digital-millennium-copyright...
(vi) A statement that the information in the notification is accurate, and under penalty of perjury, that the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly in-fringed.
Note the particular phrasing. The requirement that the information in the notification be accurate is not under penalty of perjury. The only thing that is under penalty of perjury is that you can only DMCA claim things that you have copyright to (or are a lawyer representing that entity).
And it's worse than that, because you can claim something that is totally unrelated without this penalty as long as you own the copyright you claim to be enforcing.
The only explanation I can think of is that they are relying on a sidechannel to communicate the actual transactions, which makes sense in the miner case (the utxo pool) but not in the general node case.
Beyond that, I run a BTC node occasionally and the bottleneck is validating blocks, not downloading them. Transactions are complicated enough right now that I'm only able to catch up at about 350x real-time (that is, it takes around a full cpu-day to validate a year of blocks/transactions).
The code you want to write is something like:
fn f( filename ) {
val someUrl = computeTheUrl();
val data = await http.get( someUrl );
val processedData = process(Data);
await filesystem.writeFile( filename, processedData );
}
(I'm marking "potentially blocking" calls with "await" here)But the code you want to run is an event loop:
while( program_is_running() ) {
poll_io()
poll_network()
run_ready_tasks()
}
So can you do to let you write f()? You need to invert the control between run_ready_tasks() and f(). And you need to do so in a way that allows f() to both do network io, disk io, and other blocking tasks.You're right that you can use a green thread per task to solve this problem, and "await" is then just a function that switches context to the scheduler. For various reasons, the Rust community decided that green threads were too heavy of an abstraction, and instead the compiler generates state machines (which are, in some ways, equivalent to green threads if you squint hard enough).
> if a future is inert, how can it ever detect that it is ready to make progress and call wake?
The future doesn't. When the future makes a blocking call, it needs to push its waker into some data structure handled by the top level event loop / scheduler. And then the job of the waker is to understand how to push the task back into the ready queue when whatever was being waited on completes.
The complications in Rust's design is due to their goal of making it so those compiler-generated-state-machines can be used by a library runtime -- to not require a particular standard library.
For example, Rogue Legacy is almost entirely focused on metagame progression between runs, whereas your character barely develops at all mid-run. Classic rogue-lite.
* Permadeath / "ironman mode", generally enforced by the game
* Procedural generation of game levels/encounters
* "Progression" elements, where the encounters get more difficult but the player is gaining resources to allow them to overcome those challenges (as opposed to simply gaining mechanical skill at the game)
These three elements combine to make a game where you lose early and often, but starting over gives you the opportunity to experience the game differently, due to the procedural nature as well as because you have the opportunity to invest your resources differently, hopefully making better decisions.
I don't think they need to be strictly RPGs, but the progression elements are key. Those elements are present in FTL, for example, if you consider that the ship itself is the main character.
Bones levels have been a staple of Roguelikes since Nethack, where you can find the area that one of your previous characters died. Usually this means a huge power boost if you can deal with the threat of your ghost and/or whatever killed you.
Angband is an ancient and classic Roguelike but it has a "monster memory" that accumulates the knowledge of the enemies you have fought, both in your current playthrough and all previous playthroughs. This represents a significant assistance as you progress through the game, both because the knowledge that "this beast has killed your ancestor" is a big caution sign, and also that you eventually "know" the stats of all the monsters.
Active duty generals generally do not comment on political matters. Once they have left military service it's much easier for them to give a public opinion about politics without creating a conflict of interest.
* "the Military is with [the governor]"
* "any difficulty and we will assume control"
* "when the looting starts, the shooting starts"
There's a clear causal relationship between these three statements, this is not a plea for peace, it is a threat of violence.
So I can see why someone would claim that implementing size() via strlen() "only" for small strings shouldn't be considered O(1), because strlen() is O(n) and within that class of strings the runtime is increasing as the length increases.