Doods

joined 1 year ago
[–] [email protected] 3 points 5 months ago

I think most FOSS zealots simply despise capitalism in general

No, my ideal economic system is capitalist in nature, I just don't trust western powers (the enemy) with my data. I say western powers, but that includes Russia and China and other things.

[–] [email protected] 0 points 5 months ago* (last edited 5 months ago)

I just got some idea yesterday regarding impl blocks, ready to be my respondent?

I had a big impl block with 4 levels of indentation, so I cut the block, and replaced

impl InputList {
    //snip
}

with mod impl_inputlist; and moved the impl block to a new file, and did not indent anything inside that block.

The advantage this has over just not indenting the impl block in place, is that people will have difficulty distinguishing between what's in the block and what's outside, and that's why the impl was moved to its own exclusive file, impl_inputlist.rs

Maybe I am overstressing indentation. Ss there something wrong with my setup that prevents me from accepting 4-space indentation?

I use:

Editor: Neovide

Font: "FiraCode Nerd Font Mono:h16" (16px fonts are addicintg)

Monitor: 1366x768, 18.5 inch, 10+ years old, frankenstein-ly repaired Samsung monitor.

Distance: I sit at about 40-60 Cm from my monitor.

That leaves me with a 32x99 view of code excluding line numbers and such.

[–] [email protected] 0 points 6 months ago (1 children)

Formatters are off-topic for this, styles come first, formatters are developed later.

My other reply:

How about this one? it more closely mirrors the switch example:

match suffix {
'G' | 'g' => mem -= 30,
'M' | 'm' => mem -= 20,
'K' | 'k' => mem -= 10,
_ => {},
}

How about this other one? it goes as far as cloning the switch example's indentation:

match suffix {
'G' | 'g' => {
  mem -= 30;
       }
'M' | 'm' => {
  mem -= 20;
       }
'K' | 'k' => {
  mem -= 10;
       }
_ => {},
}
[–] [email protected] 0 points 6 months ago* (last edited 6 months ago) (1 children)

How about this one? it more closely mirrors the switch example:

match suffix {
'G' | 'g' => mem -= 30,
'M' | 'm' => mem -= 20,
'K' | 'k' => mem -= 10,
_ => {},
}

How about this other one? it goes as far as cloning the switch example's indentation:

match suffix {
'G' | 'g' => {
	mem -= 30;
        }
'M' | 'm' => {
	mem -= 20;
        }
'K' | 'k' => {
	mem -= 10;
        }
_ => {},
}
[–] [email protected] 1 points 6 months ago (8 children)

A single match statement inside a function inside an impl is already 4 levels of indentation.

How about this?

The preferred way to ease multiple indentation levels in a switch statement is to align the switch and its subordinate case labels in the same column instead of double-indenting the case labels. E.g.:

switch (suffix) {
case 'G':
case 'g':
        mem <<= 30;
        break;
case 'M':
case 'm':
        mem <<= 20;
        break;
case 'K':
case 'k':
        mem <<= 10;
        /* fall through */
default:
        break;
}

I had some luck applying this to match statements. My example:


let x = 5;

match x {
5 => foo(),
3 => bar(),
1 => match baz(x) {
	Ok(_) => foo2(),
	Err(e) => match maybe(e) {
		Ok(_) => bar2(),
		_ => panic!(),
		}
	}
_ => panic!(),
}

Is this acceptable, at least compared to the original switch statement idea?

1
submitted 6 months ago* (last edited 6 months ago) by [email protected] to c/[email protected]
 

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

I am in love with this awsome document; I love its guidelines, and coding conventions.

However, when Rust was introduced into the kernel, they butchered these beautiful guidelines, I know it's hard to look at such heretic actions, but you have to see this:

The default settings of rustfmt are used. This means the idiomatic Rust style is followed. For instance, 4 spaces are used for indentation rather than tabs.

How can this even relate to the ideology of the first document? I am deeply saddened by these new rules.

I know this is "The Rust experiment", but this must be fixed before it's too late! This has to reach someone.

A counter-argument might be:

The code should be formatted using rustfmt. In this way, a person contributing from time to time to the kernel does not need to learn and remember one more style guide. More importantly, reviewers and maintainers do not need to spend time pointing out style issues anymore, and thus less patch roundtrips may be needed to land a change.

And to that I say that rustfmt is configurable per project, and if it isn't, then it has to be. Doesn't something like .editorconfig exist?

Edit: I think I read enough comments to come up with a conclusion.

At first, forcing another language's code style upon another sounds backwards, but both styles are actually more similar than I originally though, the kernel's C style is just rustfmt’s default with:

  • 80 character line.
  • 8-space hard tabs.
  • Indentation limited to 3.
  • Short local-variable names.
  • Having function length scale negatively with complexity.

The part about switch statements doesn't apply as Rust replaced them with match.*

The part about function brackets on new lines doesn't apply because Rust does have nested functions.

The bad part about bracket-less if statements doesn't apply as Rust doesn't support such anti-features.

The part about editor cruft is probably solved in this day & age.

The rest are either forced by the borrow checker, made obsolete by the great type system, or are just C exclusive issues that are unique to C.

I left out some parts of the standard that I do not understand.

This all turned up to be an indentation and line-size argument. Embarrassing!

*: I experimented with not-indenting the arms of the root match expression, it's surprisingly very good for simple match expressions, and feels very much like a switch, though I am not confident in recommending to people. Example:

match x {
5 => foo(),
3 => bar(),
1 => match baz(x) {
	Ok(_) => foo2(),
	Err(e) => match maybe(e) {
		Ok(_) => bar2(),
		_ => panic!(),
		}
	}
_ => panic!(),
}

[–] [email protected] 0 points 6 months ago

Or a source-available model.

[–] [email protected] 0 points 6 months ago (1 children)

So what should we do then? switch to something else? Host our own email service?

I really don't know.

[–] [email protected] 10 points 6 months ago (2 children)

w-what... 2 days was a looong time of not watching news, apparently.

What happened?

[–] [email protected] 1 points 7 months ago

Immediately recognized that experiment.

[–] [email protected] 2 points 7 months ago* (last edited 7 months ago) (2 children)

After searching your comment history for the string: "Doods" (all case) I have something to tell you: git off social media, it took me minutes of flipping pages to reach 5 month old comments before surrendering; I do feel like I know you as well.

Regarding the general feeling, I experience a similar thing with someone else:

@[email protected], who is noticeable for having one of the few Arabic names on Lemmy, تحريرها كلها ممكن (freeing it all is possible) and for being the moderator of [email protected], and for being from Saudi Arabia, we could tell that because:

a) He has its flag on his account.

b) He put a picture of an expensive car on top of it, further proving he is from Saudi Arabia (لا مؤاخذة) (Sorry for teasing you)

Edit: he apparently moderates many other things as well.

[–] [email protected] 1 points 7 months ago (3 children)

What does that even mean?

[–] [email protected] 13 points 7 months ago* (last edited 7 months ago) (9 children)

Didn't eat it, have to wait for sunset.

Probably tastes the same as other cheap options, they rarely differ in taste.

Edit: I am really bad at tasting things, but I don't think it tasted different from what I expected.

 
view more: next ›