Skip to content

init.q optional in one-file package #9

Description

@danielkrizian

In a lean package with just a single file, there is no need for the boilerplate overhead of init.q. At least, init.q should be optional, not mandatory.

$ ls $QPATH/my-1.0.0
my.q
$ cat $QPATH/my-1.0.0/my.q
\d .my

This conditional statement:

file: $[not 11h ~ type key pkgInfo[`file];pkgInfo[`file];` sv pkgInfo[`file],`init.q];

will resolve to false even for single-file directory:

q) key pkgInfo`file 
,my.q
q) not 11h ~ type key pkgInfo`file
0b

Was it intended?

I propose changing the line to:

file:` sv f,$[f~k:key f:pkgInfo`file;();1=count k;first k;`init.q];

That will nicely cover all scenarios:

q).utl.require"my/my.q"    / file loading scenario
q).utl.require"my"         / dir loading scenario; supports single-file dir with or without init.q

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions