@simontatham@hachyderm.io avatar

simontatham

@simontatham@hachyderm.io

Free software developer. Hobby mathematician.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

simontatham, to random
@simontatham@hachyderm.io avatar

In bash, writing ${var?} instead of just ${var} or $var means if var isn't defined then bash will throw an error and not execute your command, instead of expanding it to "" and carrying on.

mv file1 file2 $subdir # oops, I overwrote file2
mv file1 file2 ${subdir?} # error message instead of disaster

My favourite use of this is for example commands in documentation, with placeholders for the user to fill in. Then it's OK if a user accidentally copy-pastes it without filling them in!

simontatham,
@simontatham@hachyderm.io avatar

@hendric don't ask me! That decision was made literally before I was born.

simontatham,
@simontatham@hachyderm.io avatar

@muvlon @Rob_Russell thank you, I hadn't been aware of 'set -u' to make this behaviour the default!

(@hendric, I think that's what you were just asking for!)

simontatham,
@simontatham@hachyderm.io avatar

@oldherl well, the last thing anyone would accuse bash of (or any other POSIX-derived shell) is being modern!

But bash's use of ? here doesn't seem 180° away from the Rust ? operator, say. Both mean "if there's an error, propagate it to some far-away caller and do not continue running the code that would otherwise follow this statement". Every detail of the error representation is different, but the effect on control flow is identical.

mjd, to random
@mjd@mathstodon.xyz avatar

New logic post on my blog: “Well, I guess I believe everything now! ”

https://blog.plover.com/math/logic/k2.html

simontatham,
@simontatham@hachyderm.io avatar

@mjd I've always felt that my 'real' approach to this, when reasoning in practice, is in the space of 'fuzzy logic'.

Everything I 'believe' comes with an (only vaguely quantified) caveat of '… but I might have made a mistake'. And the more steps in a proof, or the more premises it uses, the more I distrust the result, because the more opportunities to be mistaken.

So after I reach a conclusion by a long piece of reasoning, I'll look for a shorter piece of reasoning that confirms it.

simontatham,
@simontatham@hachyderm.io avatar

@mjd … I think that's how I don't suffer the principle of explosion in practice, because if I do at some point realise that two of my beliefs contradict each other, then my response is to promptly downgrade my confidence level in both, so that suddenly I'm unwilling to use either one as the basis for any further thought, until I've figured out which is wrong.

simontatham,
@simontatham@hachyderm.io avatar

@mjd But where this really goes badly is that the brain (or at least my brain) is not good at remembering the provenance of all the things it thinks it believes.

So after I find and uproot one untrue belief, it may take me years to stop tripping over orphaned consequences of it, i.e. beliefs that I originally derived by deducing them from the thing I've now found out is wrong, but I'd forgotten that was how I got them, so I carried on wrongly believing them!

simontatham, to random
@simontatham@hachyderm.io avatar

The Dragon Book orthodoxy for handling source code is a regex-based lexer and an LR parser, in series, with no feedback between them and no weird edge cases.

What widely used languages can really be parsed this way? So many major languages can't: type name ambiguity, context-sensitive lexing of >>, offside rule, conditionally significant newlines, …

(Not counting really simple things like Lisp: something with a grammar the size of C, suitable as a full-scale example for a parser generator.)

simontatham,
@simontatham@hachyderm.io avatar

@xyrill Rust's type-parameter angle brackets have the same affordance as C++11 (and I think Java too these days?), that you can write two consecutive > without a space in between and the lexer will know that in that context it should lex them as two > tokens, whereas in another context they'd become a single right-shift operator token.

simontatham,
@simontatham@hachyderm.io avatar

@twilliability I must admit Go is one of the popular modern languages I don't know much about, so I went and had a look. The most immediate thing I spotted was the suspicious newline handling, which usually puts a wrinkle in orthodox LR parsing.

';' is optional at the end of a statement if there's a newline. But ';' and \n aren't interchangeable in other situations, and sometimes \n is permitted elsewhere. I'm not convinced a sensible LR grammar can express all the rules for that.

simontatham,
@simontatham@hachyderm.io avatar

Discussion last night in a legacy social network¹ suggested that the ML family might be an answer to my question, OCaml in particular:

• mandatory semicolons ⇒ no weird newline business
• whitespace completely insignificant ⇒ no offside rule
• type parameter syntax needs no >> exception
• syntax separates variable names from type names
• mandatory casing rule avoids other identifier ambiguities

I haven't checked in full detail, but it sounds plausible!

¹ pub

simontatham, to random
@simontatham@hachyderm.io avatar

One use of AI assistant tools is as a souped-up search engine: you ask a question in natural language, and you hope that it will understand its data well enough to pick out the page that really answers your question, instead of pages that just mention some of the keywords. And you usually hope in vain.

So we should re-expand the acronym: these are 'Awkward Indexing' assistants.

mjd, to random
@mjd@mathstodon.xyz avatar

But today's baffling Math SE question is similarly difficult: “A bag contains 5 balls of unknown colors. A ball is drawn and replaced twice. In each occasion it is found to be red. Again two balls are drawn at a time. The probability of both the balls red is?”

https://math.stackexchange.com/q/4903525/25554

simontatham,
@simontatham@hachyderm.io avatar

@mjd for that one, I have more sympathy for the questioner who got confused by it than I do for the person who put up the "solution" page, which as far as I can see

• computes P(first 2 draws red | k red balls in the bag) for k=1,…,5
• assumes without justification (or maybe even noticing) that those values are also P(k red balls in bag | first 2 draws red)
• scales them so they sum to 1, without explaining how a sensible method of deriving P(k red balls) would not make them sum to 1 already.

mjd, to random
@mjd@mathstodon.xyz avatar

The hardest math problem I've ever seen on Math SE is this: Four marbles are drawn from a bag. What is the probability that two of them are white?

simontatham,
@simontatham@hachyderm.io avatar

@mjd that one reminds me of https://math.stackexchange.com/q/1313076. The version at that link is the actual question, which has a sensible solution. But when it came up on a UK exam, it was misreported on at least one news site as the completely nonsensical

"Hannah has a bag of sweets. The probability of her drawing two orange sweets is 1/3. Show that n² − n − 90 = 0."

moritzdietz, to random
@moritzdietz@mastodon.social avatar

@simontatham Just found you here! Glad you made the way over from Twitter 👋🏻

simontatham,
@simontatham@hachyderm.io avatar

@moritzdietz confused – I was never on Twitter!

simontatham, to random
@simontatham@hachyderm.io avatar

Sometimes my motor cortex invents user-interface features completely by accident.

Just now I wanted to edit a particular shell function 'download_foo()' in my .bashrc. So I went to emacs, hit the keystroke to open a file, and before I quite realised what I was doing, my fingers had typed in the pathname

~/.bashrc/download_foo

as if download_foo were one file in a subdirectory, rather than one function in a source file.

Of course it doesn't work. But it might be kind of handy if it did!

simontatham,
@simontatham@hachyderm.io avatar

@lasagne yes, I think probably part of what my subconscious had in mind is that both styles of code organisation are common, and it's even quite common to change your mind about it, and break up a single source file into a subdirectory full of smaller ones. So it's not completely unreasonable that my fingers momentarily forgot which I was working with!

simontatham, to random
@simontatham@hachyderm.io avatar

The novel "1984" opens with clocks striking thirteen, perhaps intended to indicate that in the book's world, even church clocks with bells have adopted the 24-hour system.

Of course, it's impractical. You'd lose count late at night. "Was that 23 bongs, or only 22? Got to ask myself one question: do I feel sleepy?"

But here's a scheme that might make it work. Specify three clearly distinguishable types of bong representing I, V and X – and chime the hour in Roman numerals!

simontatham,
@simontatham@hachyderm.io avatar

@sgf true, of course! I was kind of thinking about it from a less dystopian perspective. I'm personally a fan of 24-hour clocks and would like to see more of them in the real world, without also committing to Ingsoc.

But there wasn't space to say that in the initial toot, so I had to hope it would be clear enough without :-)

Another oddity is: do you strike 24, or zero, at midnight? New Year would be rather underwhelming with a dramatic leadup to … no bongs.

simontatham,
@simontatham@hachyderm.io avatar

@catdad I haven't seen it, and didn't know that!

I guess in a horror movie 13 is probably meant to signify "sinister" more than "24-hour". But it might very well have been intended as also a shoutout to 1984 … especially since 1984 is pretty sinister in its own right, so that probably adds to the effect for anyone who notices!

simontatham,
@simontatham@hachyderm.io avatar

@bugshaw I'd imagined a st custards style KLANG PIP BONG BONG BONG

simontatham, to random
@simontatham@hachyderm.io avatar

We've released version 0.81. This is a SECURITY UPDATE, fixing a in ECDSA signing for .

If you've used a 521-bit ECDSA key (ecdsa-sha2-nistp521) with any previous version of PuTTY, consider it compromised! Generate a new key pair, and remove the old public key from authorized_keys files.

Other key types are not affected, even other sizes of ECDSA. In particular, Ed25519 is fine.

This vulnerability has id CVE-2024-31497. Full information is at https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-p521-bias.html

simontatham,
@simontatham@hachyderm.io avatar

@lispi314 @indigoparadox PuTTY on any platform, actually. PuTTY can run on Unix too, though it's less popular there. And its ECDSA signing code is the same wherever it's running.

Independent implementations such as OpenSSH aren't affected, that's correct.

simontatham,
@simontatham@hachyderm.io avatar

@agitatra @lispi314 @indigoparadox interesting thought – hadn't occurred to me!

Off the top of my head I'd guess the number of P521 users is relatively small. As another commenter pointed out, it's never been PuTTY's default; and generally the NIST curves seem to have mostly gone out of fashion these days, in favour of Ed25519.

So I doubt this was all the xz backdoor actors were after. It doesn't seem worth all the effort by itself. But it could have been one thing on their shopping list.

simontatham, to random
@simontatham@hachyderm.io avatar

A common piece of advice for clear writing is "Avoid double negatives".

But "avoid" and "negative" are both negatives! Why isn't it always phrased as "Negate things at most once"?

simontatham,
@simontatham@hachyderm.io avatar

@DavidBHimself I was mostly joking, but happy to have serious discussions from joke starting points!

I'm surprised that the distinction you mention matters. Surely the confusing thing you're trying to avoid is multiple semantic negations, regardless of whether they come from grammar like 'not' or verbs like 'avoid'.

'Didn't fail to misunderstand' is just as confusing as 'didn't not not understand'.

simontatham,
@simontatham@hachyderm.io avatar

@DavidBHimself I think at the point where you're writing "didn't fail to misunderstand" on stylistic grounds, you're already some distance away from the kind of writing where you pay attention to advice like "avoid double negatives", because that latter advice is intended for situations where clarity is paramount, and perhaps also where your target audience includes non-native speakers. Like user manuals.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • mdbf
  • ngwrru68w68
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • tacticalgear
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • provamag3
  • ethstaker
  • GTA5RPClips
  • modclub
  • tester
  • Leos
  • osvaldo12
  • cisconetworking
  • everett
  • cubers
  • normalnudes
  • anitta
  • megavids
  • lostlight
  • All magazines