hexaredecimal / ML

A small general purpose programming language for programming on the JVM. Package manager: https://smllregistry.github.io/
https://smllang.gitbook.io
Apache License 2.0
11 stars 1 forks source link

Struct field access #18

Closed hexaredecimal closed 2 months ago

hexaredecimal commented 2 months ago

All structs fields are public and currently I only use destructuring a way of getting the value stored in any known field. I'm thinking of simplifying the process a bit, by intoducing pointer access using the ->. Think about it, all objects in java are heap allocated and variables store references (So variables are actually pointers in this case) to those objects, so it makes sense.

struct Foo(baz: Int)

fun main(): Unit => {
  var bar = Foo { baz: 100 }
  println(bar->baz)
}
hexaredecimal commented 2 months ago

Implemented the feature on this commit. Its done.