https://toitlang.org/ logo
Including generate files, adding to extension
# help
a
So, i am generating files, and I was planning on calling them all
foo.gen.toit
However seemingly can not be imported, due to the
.
Next I tried calling them all
goo_gen.toit
However this is also annoying as It leads to needing to
import foo_gen
which also would be nice to avoid. Would it be possible to make everything after a
.
in a file actually be determined to be part of the file extension? And then also make toit allow / look for
.*.toit
and
.toit
?
k
You could use
import foo_gen as foo
as a workaround?
Would you have
import foo
look for all files of the form
foo.toit
or
foo.*.toit
and report an error if it is ambiguous?
Or would you use
import foo.gen
and just refer to it as
foo
in the code?
The latter seems a bit hard (it overlaps with looking into directories) and the former seems a bit iffy, but we already do some weird stuff to find files with
-
and
_
in them.
8.3
a
so right now I have
Copy code
import ..messages.messages_gen
// Usage of something from that imported place
Position.MT
Your point about ambiguity makes sense though
Yeah I think I have fallen over the - and _ stuff before too I just tried having some files with both - and _ in them and I dont think it was too happy about that
k
Discord formatting .... 🙂
a
maybe not
.*.toit
, perhaps a
.gen.toit
special case would be nice. Really it would / could be nice then to have these combined into a single includable resource
foo.toit
and
foo.gen.toit
in combination
but again, sounds messier than me just dealing with
_gen
for now 😛
k
I think it is a super valid point and maybe settling on a way to deal with generated stuff is a good idea. For now, maybe
_gen
is the best. Have you considered not letting the users import the
_gen
files directly, but use an
export
in a non-generated file that then holds the weird
import
?
a
Yeah, perhaps I should tihnk about this for a second too. This will be in a public repo so once I manage to get a working commit to solve my todays problem I'll think about it a little more and can link it etc 🙂
Let me know when we can take a look!