gluon icon indicating copy to clipboard operation
gluon copied to clipboard

Add glob imports

Open Marwes opened this issue 8 years ago • 2 comments

// Imports `List, monad, ...`
let { monad = { .. } } = import! "std/io.glu"
// or perhaps
let { { * } } = import! "std/list.glu"

This would import all fields (both type and value fields) into scope of the given record.

One potential problem is polymorphic records

let test record =
    // At this point all we can say is that `record` must be a record but we don't know which fields it has
    // so we can't bring any bindings into scope
    let { .. } = record
    // Apparently `x` was a field of `record` but this will still error
    x + record.x

May need to make it a hard error to use a glob on a polymorphic record

Marwes avatar Oct 10 '17 19:10 Marwes

Turns out I did have an issue for this #2 😆 . This issue is more comprehensive though so closing it in favor for this.

Marwes avatar Oct 11 '17 21:10 Marwes

Yes please :)

Maybe let * = import! "std/list.glu" or let _ = import! "std/list.glu". I would prefer a syntax that doesn't require doubly nested braces :)

It would be very useful for artistic live scripting to have glob imports. (In that scenario, speed of typing (expressing ideas) matters most, and the code can be cleaned up later.)

Boscop avatar Oct 24 '22 08:10 Boscop