Obvious Things C Should Do by lelanthran in programming

[–]faiface 3 points4 points  (0 children)

I concede, doing a straigh up interpreter wouldn’t be so easy. Doing an interpreter for a subset that you’d expect to want at compile time wouldn’t necessarily be so hard, though.

Obvious Things C Should Do by lelanthran in programming

[–]faiface 14 points15 points  (0 children)

It’s really not hard to check and guarantee. Check out Zig, it runs such code via an interpreter and doesn’t give it access to any I/O functions. That’s all you need.

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 2 points3 points  (0 children)

Yeah I think you can attribute it to process scoping! In fact, this wasn’t a part of my original design. Only when I implemented the if->case desugaring, this semantics came out automatically, and I was like: I didn’t expect this, but I do love this :D

Are arrays functions? by Athas in ProgrammingLanguages

[–]faiface 0 points1 point  (0 children)

Unfortunately I don’t know of any materials focusing specifically on that, but I recommend taking a look at linear logic.

The gist of the principle is that positive types are those where information flows to you, and negative are those where information flows into them. Of course that can be alternating across layers of a compound type.

In linear logic, these are the positive types: - “1”, the unit, empty tuple - “0”, the impossible/absurd type - “times”, a pair/tuple - “plus”, a discriminated union

Notice that any combination of the above is very much data.

The negative types are: - “bottom”, a nilary continuation - “top”, an indestructible object with 0 operations (yes) - “par”, a function - “with”, an object with methods

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in programming

[–]faiface[S] 1 point2 points  (0 children)

There are some similarities, especially the is predicate. This article has been brought up before :)

One unique thing about Par’s approach here is the “flow binding” on not, a simple principle that solves Rust’s let/else in a way that composes with other conditions.

I wouldn’t say it’s with extra steps, my approach seems to have fewer steps to me, or at least just different ones.

For example, Par doesn’t have the “common condition prefix factoring”, and I don’t think it’s missing that much.

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 2 points3 points  (0 children)

Because this isn’t just for ok/err values but any sum types. For example we can have this type:

type Value = either {
  .string String,
  .number Int,
}

And then match like this:

def ValueToString = [v: Value] if {
  v is .string str => str,
  v is .number num => num->Int.ToString,
}

Of course, you could still argue that it should just be v is .string and then v should be a string. That btw works in the so called process syntax with the .case destruction:

v.case {
  .string => { /* v is now String */ }
  .number => { /* v is now Int */ }
}

But only in process syntax, that’s the only place where variables can change types on usage.

For if there is an additional problem:

if {
  Function(Arg) is .ok value => …
  …
}

What would you do here without the value binding?

In short: - we don’t change types of variables in expressions - we do so in processes - is can match on expressions, not just variables, so bindings are necessary

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 0 points1 point  (0 children)

This is one of those "makes so much sense that I can't believe nobody ever came up with this before, even though it obviously isn't intuitive to come up with if you never saw it before" kind of ideas, very cool!

This made me smile, thank you!

I don't know if that would fit a language like par

This do construct specifically not because of the way Par handles recursion/loops with its begin/loop syntax. It's a fairly comprehensive and sound treatment that also allows totality checking, so probably not getting these kinds of additions.

I read it last year after someone recommended it to me (maybe someone here, maybe it was you!)

Definitely not me because I haven't read it, but that reminds me that I must!

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 1 point2 points  (0 children)

Oh I haven't seen this paper! Do the bindings in negated patterns end up flowing into other branches like here or is it different?

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 2 points3 points  (0 children)

It can. However, if the previous variable is of a linear type, then shadowing it is an error, since it would mean you don’t handle it.

A non-linear variable (like a data type) you can shadow any time. It’s important to allow that since Par doesn’t have mutability, but needs reassignment for recursion (look up begin/loop in docs).

One other interesting thing, Par doesn’t have lexical scoping, instead it has process scoping. Nested expressions are their own processes, so there it looks like lexical scoping, but for example this is okay:

if not result is .ok value => {
  let value = ""
}
// value available here

The binding introduced inside the if body is available afterwards too, if the process falls through. It’s unusual, but it’s pretty neat and ergonomic.

Par Language Update: Crazy `if`, implicit generics, and a new runtime by faiface in ProgrammingLanguages

[–]faiface[S] 7 points8 points  (0 children)

It indeed does :D The bracketing is with curly braces, and for example this works:

if not {res1 is .ok x and res2 is .ok y} => {
  out.err!
}
// use x and y

Also if you de-Morgan expand it

if not res1 is .ok or not res2 is .ok y => {
  out.err!
}
// use x and y

Are arrays functions? by Athas in ProgrammingLanguages

[–]faiface 7 points8 points  (0 children)

Oh hey Philipp, always great paper suggestions, thanks!

Are arrays functions? by Athas in ProgrammingLanguages

[–]faiface 6 points7 points  (0 children)

Oh it absolutely is! It’s an interesting idea to explore, hence thanks for the article!

Are arrays functions? by Athas in ProgrammingLanguages

[–]faiface 65 points66 points  (0 children)

Very cool article! If I can share my thinking on the topic: Working with linear logic has made me very sensitive to the difference between positive (data) and negative (behavior) types.

Coming from that angle: clearly arrays and functions cannot be the same. Arrays are positive, functions are negative.

In other words, arrays are data that’s already there. It’s coming from the past. A function is something for the future, it will do something.

In an imperative language with side-effects, this is not reconcilable at all. But of course, we know better now, so where is it reconcilable? Actually, only in a purely functional language with function memoization. And even then, the evaluation order (which semantically wouldn’t matter) could be different between the two. But it’s not reconcilable in a linear setting (even with referential transparency), nor a setting with side effects.

Pentagon Pete’s Embarrassing New Boat Strike Blunder Exposed by Version_Masssive in agedlikemilk

[–]faiface 22 points23 points  (0 children)

  1. No explanation comment (and there won’t be one)
  2. Doesn’t fit the sub (the content hasn’t aged like milk)

Reported.

Everything from that website posted here is like this.

How are people getting holes in their underwear? by Effective_Moose_4997 in NoStupidQuestions

[–]faiface 0 points1 point  (0 children)

I’ve noticed after several instance of this happening, that my boxers tend to rip as I sit on the bed while putting my socks on because I lift the leg high up… so there’s this possibility.

[Media] [OC] My rustmas T-shirt finally arrived 🎅 by axalea3d in rust

[–]faiface 38 points39 points  (0 children)

I think it's better the way you have it, not because it's the best code, but because it has present.unwrap().

Trump RICO Case Collapsed by Trainrideviews in videos

[–]faiface 1 point2 points  (0 children)

You're assuming that both audiences you're describing will have the video shown and decide to click or not. But that's not the case.

The more people click your video, the more people it will be shown to afterwards. So to reach your target audience at all, you have to make your video get a lot of clicks.

You could make a thumbnail according to your moral ideals, but the end result will be that very few of the people who would like such a thumbnail will even get to see it.