Tootfinder

Opt-in global Mastodon full text search. Join the index!

@azonenberg@ioc.exchange
2025-11-30 14:20:40

Wishing C had the ability to do compile-time polymorphism.
Like, I have base class Foo with Bar/Baz derived from it.
I want to be able to put a method DoSomething() in Foo and call it on a Bar or Baz object in a template, without putting a vtable in Foo or incurring the overhead of a virtual method call.
You can sort of get this effect by having Bar/Baz be separate classes with no common base and make the template just call T.Foo() for parameter T, but this eliminates som…

@xtaran@chaos.social
2025-11-25 15:28:56

#TIL you can concatenate "=~ s/…/…/r" in modern #Perl (in this case since Perl 5.14). Example:
my $a = "foobar";
my $b = $a =~ s/foo/bar/r =~ s/bar/fnord/r =~ s/fnord/gnarz/r;
say $b;
Output:
gnarzbar

@azonenberg@ioc.exchange
2025-11-25 15:24:56

Anybody else wish C and C had named function arguments like SystemVerilog module ports, and allowed you to default-value an optional argument in any position?
foo.bar(
.baz(1),
.foobar("hai"),
//foobaz is unspecified and gets a default value
.asdf(42)
);

@portaloffreedom@social.linux.pizza
2025-11-20 10:11:25

Where rust fails miserably for me it's in the lifetime syntax. The feature is pretty awesome, but the syntax is orrible:
- for some reason giving short names to variables is a bad idea, but somehow the standard around lifetime names is single letters, often just 'a
- it's extremely unclear to me which lifetime is the declaration and which one is the use of it. Example:
impl<'a> Foo for Bar<'a> {}
Which one is the declararion of the two?