Skip to content

Why force function bodies to be single expression? #394

Closed Answered by gdotdesign
danhowardms asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, and welcome 👋

I was curious whether someone could explain the reasoning behind this.

It has a number of reasons:

  1. Mint is a functional language (well sort of) so you cannot do imperative things - it's all about transforming input to output.
  2. It simplifies type checking a lot since there is no need to track the type of the variable it's only set once.
  3. I used Elm a while before creating Mint and it's the same there.

Is a function like that considered bad practice? Am I abusing the language in some way here?

Not at all, that's the reason it's there 🙂


Lately I'm favoring try blocks to where blocks (might deprecate them in the future):

fun multiply (a: Complex, b : Complex) : Complex …

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Sija
Comment options

You must be logged in to vote
3 replies
@gdotdesign
Comment options

@frnco
Comment options

@Sija
Comment options

Sija Feb 19, 2023
Maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants