Earlier quoted context omitted.
My interpretation of sgarland's question was that he meant `<file` being the entirety of the statement, i.e. typing only that at a shell prompt and pressing return.
Ah. Now I understand where the misunderstanding was. It confused me that we were talking about redirection as a replacement for useless use of cat.
Designing a programming language to speedrun Advent of Code
91–100 of 101 posts
Re: Designing a programming language to speedrun Advent of Code
#92Earlier quoted context omitted.
Ah. Now I understand where the misunderstanding was. It confused me that we were talking about redirection as a replacement for useless use of cat.
Yep I can appreciate the misunderstanding. For completeness of the discussion, I think where sgarland mentioned a sub-shell, he was possibly referencing the Bashism `$( https://www.gnu.org/software/bash/manual/html_node/Command-S... in addition to what I called a "statement" above.
Re: Designing a programming language to speedrun Advent of Code
#93Earlier quoted context omitted.
Is `<file` shorthand for `cat file`, or is that only true when used in a sub-shell?
In that fun way that shells are, for bare redirection it depends. In bash/ksh, it matches frou_dh's explanation. In zsh, it depends on how you've set the various *NULLCMD options and parameters. In csh, it is an error. Even in zsh, when configured to behave like `cat file` it still doesn't quite do that as it won't con cat enate files as it only passes the first shell word following the `<` to `cat`(or whatever you'v…
This means I get to remember an increasingly unfortunate amount of differences. I’ll add this one to the pile, thanks.
Re: Designing a programming language to speedrun Advent of Code
#94Earlier quoted context omitted.
In that fun way that shells are, for bare redirection it depends. In bash/ksh, it matches frou_dh's explanation. In zsh, it depends on how you've set the various *NULLCMD options and parameters. In csh, it is an error. Even in zsh, when configured to behave like `cat file` it still doesn't quite do that as it won't con cat enate files as it only passes the first shell word following the `<` to `cat`(or whatever you'v…
Because I hate myself I guess, I use zsh as my interactive shell, but generally write scripts for bash. The latter is mostly for portability (although with Macs stuck on 3.2 unless updated manually, that’s less true over time), and also because shellcheck doesn’t work on zsh. This means I get to remember an increasingly unfortunate amount of differences. I’ll add this one to the pile, thanks.
Re: Designing a programming language to speedrun Advent of Code
#95Earlier quoted context omitted.
In that fun way that shells are, for bare redirection it depends. In bash/ksh, it matches frou_dh's explanation. In zsh, it depends on how you've set the various *NULLCMD options and parameters. In csh, it is an error. Even in zsh, when configured to behave like `cat file` it still doesn't quite do that as it won't con cat enate files as it only passes the first shell word following the `<` to `cat`(or whatever you'v…
Because I hate myself I guess, I use zsh as my interactive shell, but generally write scripts for bash. The latter is mostly for portability (although with Macs stuck on 3.2 unless updated manually, that’s less true over time), and also because shellcheck doesn’t work on zsh. This means I get to remember an increasingly unfortunate amount of differences. I’ll add this one to the pile, thanks.
I definitely get the argument about shellcheck though, it would be nice if it supported zsh.
Re: Designing a programming language to speedrun Advent of Code
#96Earlier quoted context omitted.
Because I hate myself I guess, I use zsh as my interactive shell, but generally write scripts for bash. The latter is mostly for portability (although with Macs stuck on 3.2 unless updated manually, that’s less true over time), and also because shellcheck doesn’t work on zsh. This means I get to remember an increasingly unfortunate amount of differences. I’ll add this one to the pile, thanks.
I've mentioned this in previous posts here, but I write zsh scripts utilising all the extras that zsh gives(alternate form syntax, extensive extended globbing, zsh module support for extra functionality). It sounds stupid but it makes it really obvious that what you're writing isn't a generic shell script, and you can forgo having to think too much about whether something will work in modern bash, or MacOS pre-GPL3 b…
It definitely looks foreign, but then, so does parameter substitution in bash or zsh. There are shell scripts, and then there are those that make you break out the man pages to figure out what they’re doing.
Re: Designing a programming language to speedrun Advent of Code
#97IIRC Elm didn't have unary minus for quite some time just fine unless its author decided he really would like to have specifically unary minues but, weirdly, not any other unary operator. So, what's the deal with unary minus, why do people want it so much?
Re: Designing a programming language to speedrun Advent of Code
#98Earlier quoted context omitted.
Honestly I'm jealous of JavaScript's arrow syntax. I don't really need anything else but the arrows are nice (and Turing complete).
I really wish python would steal 'let' from JS, specifically in a block scoped form - coming from perl's 'my' as a way of life, python's (and ruby's) function level scoping and "surprise! variable just popped into existence on assignment!" behaviour really messed me up.
Re: Designing a programming language to speedrun Advent of Code
#99Earlier quoted context omitted.
I really wish python would steal 'let' from JS, specifically in a block scoped form - coming from perl's 'my' as a way of life, python's (and ruby's) function level scoping and "surprise! variable just popped into existence on assignment!" behaviour really messed me up.
Can you tell me more about the usefulness of 'let'? I'm an intermediate(?) programmer but I've worked mostly in Python, C and C++. I did one JS project and everything I saw about 'let' seemed redundant.
But my big thing is about being able to scope values to the specific block where they belong:
...
let foo;
{
let x = blah();
let y = frob(x);
foo = munge(y);
}
and the temporaries 'x' and 'y' have gone away as soon as the } happens.also, if you've ever had "fun" trying to capture a loop variable,
for (let val of things) {
callbacks.push(() => val.finish());
}
has a different 'val' for each iteration of the loop so you can do that safely without requiring some sort of copying or an intermediate function invocation to create an extra scope.Oh, and it also renders impossible certain weird constructs like
if :
some_name = ...
where now whether the some_name variable even -exists- after that if block is indeterminate without knowing which way the went.I also like being able to do e.g.
for (let thing of things) {
let blah = thing.blah;
callbacks.push(() => blah.doThing());
}
Without 'let' you'd have to write (for the first 'for' example) for (var val of things) {
callbacks.push(((val) => {
return () => { val.finish() }
})(val));
}
to perpetrate let-over-lambda to get a separate scope for the callback function.This is not my favourite thing to write, and -very- far from my favourite thing to read later.
Hopefully that gives you a better idea of why I, at least, prefer having 'let' available.
Re: Designing a programming language to speedrun Advent of Code
#100> I solve and write a lot of puzzlehunts, and I wanted a better programming language to use to search word lists for words satisfying unusual constraints, such as, “Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K.” So... Perl?
words←⊃⎕nget 'wordlist.txt' 1 ⍝ read lines tenK←'^........k.$' ⎕S '&' ⊢ words ⍝ regex filter ↑tenK/⍨{∧/1='abc'(+/∘.∊)⍵}¨tenK ⍝ count abc and filter Dyalog APL, but it's still kinda ... heavy.
Is tenK←{(10=≢⍵)∧⍵[9]='k'}¨words better?
Feel that better matches the problem spec, although requires the each