Skip to content

Commit

Permalink
Code block abbreviation changed to muselang
Browse files Browse the repository at this point in the history
Turns out there's an Emacs Muse project with the muse association
already, leading to 'interesting' highlighting on Github.
  • Loading branch information
ecton committed Apr 7, 2024
1 parent 928ad63 commit 040737c
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This is a recursive Fibonacci function. This algorithm should never be used in
production, as iterative approaches are exponentially faster, but it provides a
few opportunities to demonstrate Muse's features.

```muse
```muselang
fn fib(n) {
if n <= 2 {
1
Expand All @@ -48,7 +48,7 @@ is an important design goal.
Muse also supports *pattern matching*. Here is the same example written using
pattern matching instead of if/else:

```muse
```muselang
fn fib(n) {
match n {
n if n <= 2 => 1,
Expand All @@ -60,7 +60,7 @@ fn fib(n) {
Muse also supports *function overloading* using the same pattern match syntax.
Here's the same function using function overloading:

```muse
```muselang
fn fib {
n if n <= 2 => 1,
n => fib(n - 1) + fib(n - 2),
Expand Down
4 changes: 2 additions & 2 deletions guide/src/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ duck, then it must be a duck. To support various language features, the compiler
generates code that tries to use a value in a specific way. For example, the
code generated by these two expressions is identical:

```muse
```muselang
let a = [0, 1, 2];
# Access the first element using indexing.
Expand Down Expand Up @@ -112,7 +112,7 @@ Muse, it unwinds the stack to the exception handler.
In Rust, it's much easier to check for 0 compared to catching an panic. In Muse,
the try operator (`?`) makes it easy to turn any exception into `nil`:

```muse
```muselang
# '//' is the integer division operator
(1 // 0)?
```
Expand Down
4 changes: 2 additions & 2 deletions guide/src/reference/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ When a `let` expression is evaluated, all bound identifiers will not be able to
be reassigned to. In Muse, these are simply called *values*. While values cannot
be reassigned to, they can be shadowed by another declaration.

```muse
```muselang
# Basic value declaration
let a = 42;
# Values declared using destructuring
Expand All @@ -37,7 +37,7 @@ done using the `break`, `continue`, `return`, or `throw` expressions.
When the `var` keyword is used, all bound identifiers become *variables*. Unlike
values, variables can be assigned new values.

```muse
```muselang
# Basic declaration
var a = 42;
# `var`s can have their values updated through assignment.
Expand Down
12 changes: 6 additions & 6 deletions guide/src/reference/bitwise.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ functionality.
The bitwise or expression produces a new value by performing a logical or
operation on each corresponding bit in the two operands.

```muse
```muselang
let 0b101 = 0b100 | 0b001
```

Expand All @@ -39,7 +39,7 @@ let 0b101 = 0b100 | 0b001
The bitwise excusive or (xor) expression produces a new value by performing a logical xor
operation on each corresponding bit in the two operands.

```muse
```muselang
let 0b101 = 0b110 ^ 0b011
```

Expand All @@ -48,7 +48,7 @@ let 0b101 = 0b110 ^ 0b011
The bitwise and expression produces a new value by performing a logical and
operation on each corresponding bit in the two operands.

```muse
```muselang
let 0b100 = 0b110 & 0b101
```

Expand All @@ -57,14 +57,14 @@ let 0b100 = 0b110 & 0b101
The bitwise shift expressions produce a new value by moving bits left or right
by a number of bits, filling in any empty bits with 0.

```muse
```muselang
let 0b100 = 0b010 << 1;
let 0b001 = 0b010 >> 1;
```

The shift-right expression is sign-preserving when operating on signed integers:

```muse
```muselang
let -2 = -4 >> 1;
```

Expand All @@ -73,7 +73,7 @@ let -2 = -4 >> 1;
The bitwise not expression produces a new value by performing a logical not
operation on each bit in the operand.

```muse
```muselang
let -1 = !0;
let 0uxffff_ffff_ffff_ffff = !0u;
```
6 changes: 3 additions & 3 deletions guide/src/reference/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ When Muse checks if two values are equal or not equal, Muse will try to
approximately compare similar data types. For example, all of these comparisons
are true:

```muse
```muselang
let true = 1 == 1.0;
let true = 1 == true;
let true = 1.0 == true;
Expand All @@ -35,7 +35,7 @@ let true = 1.0 == true;
`nil` is only considered equal to `nil` and will be not equal to every other
value.

```muse
```muselang
let true = nil == nil;
let false = nil == false;
```
Expand All @@ -58,7 +58,7 @@ Muse interprets `0 < a < 5` as `0 < a && a < 5`. This form of chaining
comparisons can mix and match all comparison operators. Consider a longer
example:

```muse
```muselang
let a = 1;
let b = 2;
Expand Down
8 changes: 4 additions & 4 deletions guide/src/reference/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ application. In Rust, the result will be `Err(_)`.
Any value can be used as an exception, and handling specific functions is done
using pattern matching. Consider this example:

```muse
```muselang
fn first(n) {
try {
second(n)
Expand Down Expand Up @@ -62,7 +62,7 @@ Catching any error can be done in one of two ways: using an identifier binding
or using an arrow catch block. In the next example, both functions are
identical:

```muse
```muselang
fn identifier_binding() {
try {
1 / 0
Expand All @@ -86,7 +86,7 @@ fn arrow_catch() {
To catch multiple errors raised by inside of a try block, a match block can be
used:

```muse
```muselang
fn checked_area(width,height) {
if width == 0 {
throw :invalid_width
Expand All @@ -111,7 +111,7 @@ A `try` block without a `catch` block will return `nil` if an exception is
raised. Similarly, the try operator (`?`) can be used to convert any exception
raised to `nil`. These examples produce identical code:

```muse
```muselang
try {
1 / 0
Expand Down
2 changes: 1 addition & 1 deletion guide/src/reference/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function](./functions.md#arrow-functions), or an [inline if](./if.md#inline-if).
The precedence of these operators matches the order they are listed in. For
example, these two ways of assigning to `my_function` are identical:

```muse
```muselang
var my_function = nil;
my_function = n => n * 2 if n > 0;
Expand Down
10 changes: 5 additions & 5 deletions guide/src/reference/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Anonymous functions do not have a name specified at the time of creation. They
can only be called by calling the function returned from the function
expression:

```muse
```muselang
let square = fn(n) => n ** 2;
let 4 = square(2);
Expand All @@ -49,7 +49,7 @@ using the identifier as its name. These examples are identical to the anonymous
function examples, except they utilize named functions instead of `let`
expressions to declare the function.

```muse
```muselang
fn square(n) => n ** 2;
let 4 = square(2);
Expand All @@ -75,7 +75,7 @@ an open curly brace (`{`) is found after the `fn` keyword or after the
function's name, the contents of the braces are interpretted as a set of match
patterns:

```muse
```muselang
fn area {
[width] => width * width,
[width, height] => width * height,
Expand All @@ -100,7 +100,7 @@ When a function executes, the result of the final expression evaluated will be
returned. The `return` expression can be used to exit a function without
executing any additional code.

```muse
```muselang
fn my_function() {
return;
this_expression_wont_be_evaluated
Expand All @@ -111,7 +111,7 @@ my_function()
The `return` expression can also be provided an expression to return as the
result of the function. If no value is provided, `nil` is returned.

```muse
```muselang
fn checked_op(numerator, denominator) {
if denominator == 0 {
return numerator // denominator;
Expand Down
12 changes: 6 additions & 6 deletions guide/src/reference/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the `if` expression: standalone and inline.
The standalone `if` expression enables executing an expression when a condition
is true:

```muse
```muselang
let 42 = if true {
42
};
Expand All @@ -30,7 +30,7 @@ let nil = if false then 42;
If the `else` keyword is the next token after the "when true" expression, an
expression can be evaluated when the condition is false.

```muse
```muselang
let 42 = if false {
0
} else {
Expand All @@ -42,7 +42,7 @@ let 42 = if false then 0 else 42;
Because `if` is an expression, the expressions can be chained to create more
complex if/else-if expressions:

```muse
```muselang
fn clamp_to_ten(n) {
if n < 0 {
0
Expand All @@ -62,21 +62,21 @@ let 10 = clamp_to_ten(11);
An inline if expression returns the *guarded expression* if the condition is
true, or `nil` when the condition is false:

```muse
```muselang
let 42 = 42 if true;
let nil = 42 if false;
```

Similar to the standalone `if` expression, `else` can be used to execute a
different expression when the condition is false:

```muse
```muselang
let 42 = 0 if false else 42;
```

Inline if statements can also be chained:

```muse
```muselang
fn clamp_to_ten(n) {
0 if n < 0
else 10 if n > 10
Expand Down
2 changes: 1 addition & 1 deletion guide/src/reference/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A label is the `@` character followed by an identifier, e.g., `@label`. Labels
can be applied to blocks or loops to allow controlled execution flow in nested
code.

```muse
```muselang
var total = 0;
@outer: for x in [1, 2, 3] {
for y in [1, 2, 3] {
Expand Down
10 changes: 5 additions & 5 deletions guide/src/reference/logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ conditions:
The logical or expression is a short-circuiting operator that returns true if
either of its operands are truthy.

```muse
```muselang
let true = true or true;
let true = true or false;
let true = false or true;
Expand All @@ -42,7 +42,7 @@ let false = false or false;
The short-circuiting behavior ensures that once the expression is known to
return `true`, no remaining chained expressions will be evaluated:

```muse
```muselang
# "error" is not evaluated
let true = true or error;
```
Expand All @@ -52,7 +52,7 @@ let true = true or error;
The logical exclusive or (xor) expression is an operator that returns true if
one of its operands is truthy, but not both.

```muse
```muselang
let true = true xor false;
let true = false xor true;
let false = true xor true;
Expand All @@ -66,7 +66,7 @@ This operator can not short-circuit, so both expressions are always evaluated.
The logical and expression is a short-circuiting operator that returns true both
of its operands are truthy.

```muse
```muselang
let true = true or true;
let true = true or false;
let true = false or true;
Expand All @@ -76,7 +76,7 @@ let false = false or false;
The short-circuiting behavior ensures that once the expression is known to
return `false`, no remaining chained expressions will be evaluated:

```muse
```muselang
# "error" is not evaluated
let false = false and error;
```
2 changes: 1 addition & 1 deletion guide/src/reference/lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ These expression are chainable. For example, this code accesses a value from a
list within a list by chaining the index operator after invoking `list.get(0)`
function:

```muse
```muselang
let list = [[1, 2, 3], [4, 5, 6]];
let 2 = list.get(0)[1];
```
8 changes: 4 additions & 4 deletions guide/src/reference/loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ execution can be affected by these operations:

# Infinite Loop

```muse
```muselang
var n = 0;
let nil = loop {
if n % 2 == 0 {
Expand All @@ -48,7 +48,7 @@ point the loop exits.
A while loop checks that a condition is truthy before executing the loop body,
and continues repeating until the condition is not truthy.

```muse
```muselang
var n = 0;
while n < 10 {
n = n + 1;
Expand All @@ -63,7 +63,7 @@ truthy. This is different from a While loop in that the condition is only
checked after the first iteration of the loop. The `continue` expression will
continue iteration just prior to the condition evaluation.

```muse
```muselang
var n = 1;
loop {
n = n * 3;
Expand All @@ -82,7 +82,7 @@ If the iterator returns an item that does not match the pattern, the next
element will be requested and the loop body will not be executed for that
element.

```muse
```muselang
var sum = 0;
for n in [1, 2, 3] {
sum = sum + n
Expand Down
Loading

0 comments on commit 040737c

Please sign in to comment.