Hacker Newsnew | past | comments | ask | show | jobs | submit | tordek's commentslogin

> I would like to know the reasoning behind this. It sure seems clever but what is the advantage that this provides?

Since C provides very little metaprogramming capabilities, this was the only way to obtain what I wanted: Most (if not all) other testing libraries/frameworks require some boilerplate to start testing (namely: defining your `main` function, which calls all of your tests). Additionally, every time you write a new test, you must remember to add it to your `main` function.

I decided that those two things were bothersome enough, so I wrote a proof of concept that evolved into a large project with tons of useful features beyond that.


Would you mind expanding a bit on the usage of Range?

The simplest case involving items is clearly `items=10-20`, but that has its own set of problems (your set must be ordered; I assume you'd use the key you're sorting over as your `ranges-unit`).

The place where this solution seems less than ideal is when you want to start from an id, but get a certain number of items. That is, the "infinite scroll" use case: If you simply do "sort by date, discard 10, return next 10 items", then you have a race condition where you do your first request, a second agent adds a new item, and you do your second request: the last item from the previous page is now the first item from the current page.

So, ideally, I want to request: "Ordered by date, where id > <last-id>, 10 items".

If you're strict about the definitions of `Range`, this doesn't seem possible.

Maybe the best way to do this would be `Range: items=decacfb98eface89+10` or similar?


Additionally, how would you signal "End of List"?


Of note: There are several of us in #mongrel2 on Freenode, and there are periodic patches from us :).


But that makes no sense, it is whitespace, and it has semantic significance (hence being significant). Whitespace was not significant in older versions of Fortran, and that allowed you to write

    DO30I=10,100
which was interpreted as

    DO 30 I = 10, 100

An amusing bug I saw in Expert C Programming mentioned how somebody once typed e dot instead of a comma, and

    DO 30 I = 10. 100
ended up interpreted as a simple real assignment:

    DO30I = 10.1


In your last example, `.find('.more_stuff')` works on the value returned from `.addClass('other')` (or so it'd seem), so it behaves differently.


Which, with jQuery, is the same as the results from the most-recent selector in the chain (in this case, the .find('.stuff') before it). Normally though, you'd be absolutely correct, and that example would need to nest the .addClass('other') inside its .find so it doesn't pollute the next .find:

  $('.class')
    .find('.sub').remove()
    .find('.stuff')
      .addClass('other')
      .find('.more_stuff').removeClass('things')
    .filter('li').appendTo('#my_list')


As said elsewhere: "Declaration follows use".

    int *foo;
means "foo is a pointer to int". But that's explained different from how it's written. More clearly, you can say that "foo" is an int. Then, doing

    int *foo;
    foo = 50;
is obviously wrong because "foo" is not an int; however

    int *foo;
    *foo = 50;
is correct.

Similarly for arrays:

    int *foo[50];
means "foo is an array of pointers to int", or "
foo[5] is an int".

From there follows that & is the antithesis of , and they negate each other:

    int *foo; //foo is a pointer to int.
    &*foo; //the address of the contents of foo
    foo; // same as above, but shorter.


Sorry, that didn't make much sense to me - in your first example, you can't say "foo is an int", because it's not, it's a pointer to an int. And in your last example, you can't say "foo[5] is an int", because it's not, it's a pointer to int.

In response to the original question, I think the answer is that

  int *foo;
is a common way of writing it because that's the way the compiler resolves it. As mentioned elsewhere,

  int* foo, bar;
is equivalent to

  int *foo; int bar
so treating the star as part of the type can cause problems.

But I agree fully - it makes a lot more sense to me to consider the pointer star as a flag on the type, not a modifier to the name. Just one of the many warts on C and C++ that make me happy I have to use them so infrequently...

[Edit: formatting, stars were getting swallowed when put inline]


> [Edit: formatting, stars were getting swallowed when put inline]

The same thing happened to the post you're responding to, and that's why it's not making sense to you. The author really meant to say star-foo and star-foo[5], but instead italicized a bunch of text in between.


D'oh.

Don't know how I didn't realize that, given that my response got messed up so that my "corrected" version read exactly like the one I was confused about...

Please disregard everything I said, in that case. :)


How so?

         +-----------+
         | +-+       |
         | ^ |       |
    char *foo[10][20];
     ^   ^   |       |
     |   +---+       |
     +---------------+
* foo is

* an array of ten arrays of 20

* pointers to

* char


Following the procedure as written:

         +-------+ 
         | +-+   |
         | ^ |   |
    char *foo[10][20];
      ^  ^   |   |
      |  +---+   |
      -----------+
It mentions, in rule 1, handling tokens of the form [] or [X], but not multiple occurrences of these.

This is indeed rather nitpickish of me, but on the other hand, one thing that you at least need to know in that case is in what order you read the numbers - left-to-right, or right-to-left (is foo[10][20] a 10-array of 20-arrays or a 20-array of 10-arrays?). Not mentioning this leaves one (at least, it left me) with the impression that multiple occurrences were already handled by this rule as written, which is, as demonstrated, false.


> Wait are you saying I have to be content with who I am?

When did he ever tell you to stop bettering yourself?

> What do you mean I can't expect my employer to validate my passions in life?

Because your passions are yours, and yours alone. You could get miraculosuly lucky and get an employer that shares some of your passions and lets you work in them... or you could remove chance from the equation and write code on your own, and open source it.


Sarcasm.... The internet doesn't get it.


http://netlib.bell-labs.com/cm/cs/pearls/cto.html

Millions of numbers in a single megabyte may be interesting.


I'm righty and can only raise my right one. But I can also jiggle my left ear...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: