percyqaz / Percyqaz.Shell

Toolkit to add command line/IPC capabilities to your F# application
MIT License
1 stars 0 forks source link

Modules #2

Open percyqaz opened 2 years ago

percyqaz commented 2 years ago

Loose idea I have

Modules would have syntax like

module NAME
{
    let ...
    let ...

    fn ...
    etc
}

Can then be loaded from files/maybe interop sources

Can call functions and variables via MODULENAME::$variable and MODULENAME::function ..args

Useful for having importable namespaces of shell features Useful for creating a standard library to drive the shell as a general purpose utility

percyqaz commented 2 years ago

especially useful for organising many related commands/variables

modules can really just be objects with a special syntax for accessing commands

percyqaz commented 2 years ago

Modules can really just be objects

module Mod
{
    let bind = |x| -> 5
}

is a construct that creates an object with properties set to those bindings

and

Mod::bind arg1 arg2

calls a particular value exported by a module

The constructor doesn't need to exist for my current purposes, just the syntax for calling parts of modules

I like :: more than : because module:module:bind looks less cool than module::module::bind Also because of its similarity to C

percyqaz commented 2 years ago

Should modules be their own construct? Being values implies they can be passed into functions (I'm ok with this) Being objects implies all objects are modules for help purposes Being objects lets you inspect them in other ways (I think I'm ok with this)

Basically are first order modules useful -- Probably not because objects already exist

Yes overall I think it should be a separate concept to objects

percyqaz commented 1 year ago

I had an issue with the syntax construct and I can't remember what Anyway modules exist and can be defined from the F# environment end but not by scripts