HNHacker News
TopNewBestAskShowJobs

dfawcus

574 karma · joined March 23, 2019

submissionscomments
dfawcus··on The Cost of a Closure in C
It is possible to transform the pure Rosetta form of GNU nested function similar to the pure C, such that it doesn't need any stack trampoline. I wonder if that would be closer in performance to the pure C form.

(I can't be bothered to run his benchmarks)

    #include <stdio.h>
    typedef struct env_ E;
    typedef struct fat_ptr_ Fp;
    typedef int fn(E*);
    struct fat_ptr_ {
      fn *f;
      E  *e;
    };
    #define INT(body) ({ int lambda(E*){ return body; }; (Fp){lambda,0}; })
    struct env_ {
      int k;
      Fp xl; Fp x2; Fp x3; Fp x4;
    };
    #define FpMk(fn,e) {fn, e}
    #define FpCall(fn) (fn.f(fn.e))
    int main(){
      int a(E env, Fp x5){
        int b(E *ep){
          return a( (E){--(ep->k), FpMk(b, ep), ep->xl, ep->x2, ep->x3}, ep->x4 );
        }
        return env.k<=0 ? FpCall(env.x4) + FpCall(x5) : b(&env);
      }
      printf(" %d\n", a( (E){10, INT(1), INT(-1), INT(-1), INT(1)}, INT(0)) );
    }
dfawcus··on Stacked Diffs with git rebase —onto
Even for 'normal' rebases of a multi-commit series (without named feature branches), I habitually use the --onto form. It is simply easier to conceptualise what is happening if one is explicit about the 3 references.

As such, using it for the situation described in the piece then becomes a trivial matter, especially if one also habitually runs a graph viewer - I generally have one or more instances of gitk running all the time.

dfawcus··on Checked-size array parameters in C
yet if one does that, and has suitable warnings turned on, GCC will complain:

    array2.c: In function ‘main’:
    array2.c:25:17: warning: passing argument 1 of ‘arr_fn2’ from incompatible pointer type [-Wincompatible-pointer-types]
       25 |         arr_fn2(array);
          |                 ^~~~~
          |                 |
          |                 char *
    array2.c:13:22: note: expected ‘char (*)[15]’ but argument is of type ‘char *’
       13 | void arr_fn2(Arr_15 *arr) {
          |              ~~~~~~~~^~~

The above was -Wall -Wextra

Or are you just referring to the function where one defines it as apparently 'pass by value'?

dfawcus··on Checked-size array parameters in C
depending upon how one has structured the code, a less painful way to write the same is:

    typedef char array[5];

    void do_something(array *a) {
        enum { a_Size = sizeof *a };
        memset(*a, 'x', a_Size);
    }
it rather depends upon how painful it will be to create a bunch of typedefs.

Beyond a certain point, if there are too many arrays of the same size with different purposes, my inclination is to wrap the array in a struct, and pass that around (either by pointer or value depending upon circumstances.)

The existence of the decaying form is if I recall correctly a backward compatibility thing from either B or NB; simply because in one or the other pointers were written in the (current) array syntax form.

dfawcus··on Jury trials scrapped for crimes with sentences of less than three years
They're not gone yet. They have to pass legislation to achieve the scrapping.

So we still have the ability to make our views known. Write to MPs in the first instance. Basically, they need to be informed that this is a bright red line.

However, I suspect it'll take a mass demo in London to really drive the point home.

Only 110k at the UTK rally? I'd hope a demo in opposition to this proposal would completely choke up London.

dfawcus··on WordPress plugin quirk resulted in UK Gov OBR Budget leak [pdf]
Well even at the GE, his party was less popular than the previous offer by Corbyn. Labour only really got in because of the collapse of the Tory vote.

2019 GE Votes

    Labour: 10,269,051   22% R  32% T
    Tory:   13,966,454   29% R  44% T
    LibDem:  3,696,419    8% R  12% T
2024 GE Votes

    Labour:  9,708,716   20% R  34% T
    Tory:    6,828,925   14% R  24% T
    LibDem:  3,519,143    7% R  12% T
Also % Registered, % Turnout

So that he got even more unpopular seemed a given, unless he managed to be competent and actually improve things for the people who elected his party.

dfawcus··on UK Government plans new powers to label dissenting movements as 'subversion'
Their initial statement the day of (or after) the action at the RAF base was something like:

  "disabled aircraft using paint and crowbars"
Which even if they didn't use crowbars, then would seem to require the turbines be inspected for alignment and physical damage.
dfawcus··on UK Government plans new powers to label dissenting movements as 'subversion'
Good for you.

However many of us don't believe he has actually changed in his views since his days editing, and writing articles for Socialist Alternatives.

dfawcus··on UK Government plans new powers to label dissenting movements as 'subversion'
One of the problems with Palestine Action is the violent protests they have previously engaged in.

There is a trial in progress at the moment relating to an attack on Elbit Systems where one of the "protestors" seemed to attack a WPC with a sledgehammer. Apparently having caused serious harm to her spine.

https://www.bbc.com/news/articles/c79727zeqyvo

So the folks holding signs expressing their support for the group once it has been proscribed (I believe under the TA 2000) are somewhat ill advised.

If they disagree with the proscription, what they should probably be doing it assisting in the Judicial Review of that proscription which is currently ongoing. Certainly they should be waiting until after the review before expressing any support.

As even if the proscription is overturned, those who expressed support for what is currently viewed as a terrorist org may not have the personal consequences of their support undone.

dfawcus··on UK Government plans new powers to label dissenting movements as 'subversion'
Look up our current PMs history.
dfawcus··on UK Government plans new powers to label dissenting movements as 'subversion'
There are two of more things driving the cumulative protest legislation push. The test will come when the first use it, and we find out which they want to use it against.

1. We have had various highly disruptive repeated "climate" protests (Just stop Oil, etc)

2. We have had over a year of "pro Palestinian" hate marches, more or less every weekend.

3. We have had repeated protests outside various hotels repurposed as hostels for housing illegal migrants.

Of these the latter is the most recent, least disruptive, but most embarrassing for the regime. The regime seems to be complicit with the second.

I suspect most folks expect this power to be used against '2', but I'd not be surprised if it was used against '3' instead.

dfawcus··on EU set to adopt ChatControl negotiating mandate tomorrow without discussion
Because of the nature of the treaties forming the EU, and the structures it generates.

It is basically a regulatory union, constructed so as to transpose power to the center, then hold it there.

It can't allow the people to have too much say, as that is "populism", which gets in the way of the bureaucracy doing its thing.

The only way to end / prevent this proposal from being repeated until "success" is to pass another treaty entrenching that something like Chat Control is forbidden.

That is an extremely low probability event, and gets lower as more member states join.

dfawcus··on GCC SC approves inclusion of Algol 68 Front End
OK - assuming you're referring to 'char ptr[static 15]' as the 'static trick', then yeah - other compilers do not complain.

However the other form 'char (*arr)[15]' has always been available, and is complained of in other compilers.

I believe I remember using it in DOS based C-89 compilers back in the early 90s, possibly also in K&R (via lint) in the 80s.

NB: icc, msvc, mvc complain about the misuse of the traditional version if one adjusts your godbolt example.

Yes one has to build with warnings forcing errors, which takes a bit of work to achieve if the code has previously been built without that.

dfawcus··on GCC SC approves inclusion of Algol 68 Front End
Then don't allow it to decay:

    void arr_fn(char (*arr)[15]) {
        enum { len = sizeof *arr }; printf("len of array: %d\n", len);
        printf("Got: %.*s\n", len, *arr);
    }
    void sptr_fn(char ptr[static 15]) { printf("Got: %s\n", ptr); }
    int main(void) {
        char array[15] = "Hello, World!";

        arr_fn(&array); sptr_fn(array); return 0;
    }
Using gcc (and similarly clang) removing the '15' from 'array', and allowing it to allocate it as 14 chars will result in warnings for both function calls.

One can hide that ptr to array behind a typedef to make it more readable:

    typedef char (Arr_15)[15];
    void arr_fn2(Arr_15 *arr) {
What do you mean by 'the static trick'? Is that what I have in sptr_fn()?
dfawcus··on GCC SC approves inclusion of Algol 68 Front End
I had a small programming task a while ago, and decided to try doing it algol68 (using the algol68 genie interpreter) simply because I'd had some exposure to the language many years ago at Uni.

It was an AWK like task, but I decided up front it was too much trouble to do in AWK, as I needed to build a graph of data structures from the input data.

In part the program had an AWK like pattern matching and processing section, which wasn't too awkward. I found having to use REF's more trouble that dealing with pointers, in part due to the forms of auto dereferencing the language uses; but that was expected.

The real problem though was that I ended up needing something like a map / hash-table, and I concluded it was too much trouble to write from scratch.

So in the end I switched the program to be written in Go.

That then suggests a few things to me:

    - it should have an extension library (prelude) offering some form of hash table.

    - it would be useful to add syntax for explicit pointers (PTR keyword) which are not automatically dereferenced when used.

    - maybe have with either something like the Go (or Zig) style syntax for selecting a member of a pointed to struct (a.b) and maybe Zig like explicit defer (ptr.\*).
That latter pointer suggestions because I found the "field OF struct" form too verbose, and especially confusing when juggling REFs which may or may not get auto dereferenced.
dfawcus··on Concrete Shipbuilding – Argentina
There is one at Seaton Sluice, now (almost?) completely buried by sand.

https://www.flickr.com/photos/36891793@N08/8033301173/

dfawcus··on I just want working RCS messaging
I did notice one oddity with RCS on Apple, namely that initially it could not be enabled if the device was in Lockdown Mode. In one of the recent updates, 18.x for some lowish value of x, that was fixed, and so my iPhone now has RCS enabled.

However, I found that Apple have screwed another part of Lockdown Mode as of 18.7.2.

If a website makes use of Javascript, and is viewed in Safari then the page reloads a couple of times then crashes with no content but an error message. That can generally be fixed by turning off Javascript in Settings, or by turning off Lockdown mode for that specific web page - rather defeating its purpose.

dfawcus··on The disguised return of EU Chat Control
I find it sadly amusing that the proposed "compromise text" document is marked as "(Text with EEA relevance)" - i.e. they want to push it on the EEA states.
dfawcus··on The disguised return of EU Chat Control
These things are rather pointless, as one could always use a standalone encryption app, and copy&paste text to and from a non encrypted chat app. i.e. how one originally made use of PGP.

The difficulty which PGP had of key exchange could be handled somewhat like Signal does now, via a personal physical sync of the phones.

At which point, the authorities will still be able to make use of "traffic analysis" as they always have. So they'll be able to tell which parties are communicating, but not what is being said.

dfawcus··on The history of Casio watches
I've a Citizen solar power watch from around '98 or '99.

It still runs, although the cell seems to have aged, and now needs longer in the sun to charge. In the winter when not being worn, I have to leave it on a window ledge to get sufficient charge.

dfawcus··on A Note on Fil-C
I wonder if some of the Apple provided Clang annotations for bounds checking can be combined with Fil-C?

That then may allow for some of the uses to be statically optimised away, i.e. by annotating pointers upon which arithmetic is not allowed.

The Fil-C capability mechanisms for trapping double-free, and use-after free would probably have to be retained, but maybe it could optimise some uses?

dfawcus··on A Note on Fil-C
Now that suggests an idea: Objective-Fil-C !
dfawcus··on The English language doesn't exist – it's just French that's badly pronounced
I was not referring to the well known 4 letter words used to describe parts of the anatomy. They merely get used for emphasis.

Under fight / violence / battle conditions, the active vocabulary is Germanic, and not lacking in expressive power, nor subject to misunderstanding.

dfawcus··on The English language doesn't exist – it's just French that's badly pronounced
English only has sex, not gender. He, She, It.

The commonly cited example of referring to ships as 'she' is simply an affectation, grammatically a ship is an it.

Or can you provide another example I may have overlooked?

dfawcus··on The English language doesn't exist – it's just French that's badly pronounced
Nah - there are two vocabularies, the 'posh' Norman French one, and the common western Germanic one. (There is also an admixture of Norse influence, so the combination of Old English (Angles, Saxons, Jutes, Frisians) with Old Norse then knocking the edges off. That probably did for grammatical gender.)

The Germanic core still generally gets used by all in high stress environments.

dfawcus··on California invests in battery energy storage, leaving rolling blackouts behind
The increase in use of wind, being intermittent and non-dispatchable means there has to be 1-for-1 back up wind generation. That is gas.

We also have periods in the winter (so solar of little to no use), where we can have a week or two of no wind.

As the gas generators are not run constantly, they're more expensive than if they were. There are various (at least 3) UK "gridwatch" sites available, offering real time and historical generation mix. Maybe have a look.

From memory, so probably flawed, we still tend to depend upon nuclear and gas for around 40 - 50 % of our generation (nuke being low - say between 5 and 10).

dfawcus··on California invests in battery energy storage, leaving rolling blackouts behind
The interconnectors between UK and the continent are HVDC.

As such they are essentially massive switching-mode PSUs, and there is no possibility of having a synchronised connection, as the AC has to be synthesised, following the local spinning iron.

dfawcus··on How England misplaced its first king
That does seem to miss the fact that by then there was not a 'Viking king of Northumbria'. The Danelaw did not fully extend in to Northumbria.

My recall of history is that Northumbria had more or less split back in to Deira and Bernicia. With the Vikings having control south of the Tees, but north of the Tyne it was still an Kingdom of the Angles. Albeit possibly a client Kingdom, that seems a bit uncertain.

https://en.wikipedia.org/wiki/Northumbria#Northumbria_and_No...

https://en.wikipedia.org/wiki/Bernicia#Rump_of_Northumbria

https://en.wikipedia.org/wiki/Rulers_of_Bamburgh

So that portion only really became part of a unified England per-se after the Norman conquest, and the "Harrying of the North."

Certainly the English spoken in Northumberland to this day, is apparently heavily influenced by the Old Anglic language.

dfawcus··on UK banks still run software code written more than 60 years ago
For 10p, 5p and 2.5p quantities, that wouldn't be an issue as following decimalisation, those simply reused the Florin, Shilling and Sixpence coins.

Also yielding:

  0.5p = 1.2d
    1p = 2.4d
    2p = 4.8d
    3p = 7.2d
    4p = 9.6d
I wonder how they handled those values with their mapping layer? Did the add a layer for handling fifths of an old penny?

(The 2.5p coins, then eventually also the 0.5p "new pennies" went out of circulation.)

dfawcus··on Yet Another TypeSafe and Generic Programming Candidate for C
Maybe because one is working on a legacy C program, and for various reasons adding C++ to said program is too risky or expensive?
← PreviousPage 2 of 17Next →