You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs state (and have stated for many years) that a unit declaration at the beginning of a file may be preceded only by comments and use statements.
However, any declaration of sub EXPORTmust precede the unit declaration.
Neither requirement seems to be tested in any roast tests that I could find (but I'm still a novice at searching in the roast repo).
The blocked docs issue Raku/doc#2148 is over seven years old, and the problem it describes is still in the current docs.
@librasteve, the original issue stated that you can in fact declare any number of subs before a unit package. I just tested declaring an empty sub EXPORT followed by a unit package and got no errors
There was some discussion of that on the other issues linked above, and there's reluctance to document things that ROAST doesn't require, which makes sense, since all such behavior is technically implementation detail and not part of the language we're documenting.
Discussion to come to a consensus (about what ROAST should require here) got bogged down in the now-closed rakudo issue rakudo/rakudo#2020, which is why I opened this one, because lack of such consensus is what's blocking the docs issue Raku/doc#2148.
My own opinion about what the consensus seemed to be groping toward is that sub EXPORTand the like should be allowed (like comments and use statements) before a unit declaration, but that any sub not explicitly allowed there should be disallowed.
By 'and the like' I mean any other ALL-CAPS subs clearly connected to the namespace in question (as EXPORT is) but which for some reason have to live outside that namespace. This is intended to cover both future developments and also possibly other existing language features that I haven't learned about yet: the general principle is that there's an allowlist for this, and anything not on it would cause squawking.
@arkiuat - agree that adding to ROAST first is a good plan.
I have written (literally) a couple of ROAST tests - having seen you work in the docs, I am sure that you will find it straightforward (and of course there are many out there to help if you get stuck)
@librasteve thanks, but it's not that I'm hesitant to submit a PR for ROAST, or even that I'm not sure how to test for this particular thing. It has just become clear to me that this isn't going to make it to the top of my priorities anytime soon, if ever.
At worst, the status quo is that anyone can add a unit class/module/package/whatever to the end of any file that doesn't define other classes/packages/etc, as long as it's the last thing in the file, but the docs say that you can't do this, perhaps in hopes of preventing people from making a habit of it. I'm okay with leaving that as is because there are bigger fish to fry, so I'll leave it for someone who cares about it more than I do.
Originally I was just trying to knock off an old blocked docs issue, but the scope has creeped. We're just talking about a way to save a level of indentation here.
OK - thanks for explaining - we all have our various foci and time constraints.
On a matter of "issue etiquette" I personally prefer "issues that we know are real, but have no prospect of getting resourced since we consider them too low priority" be Closed (ie both this problem-solver and the referenced doc issue above), and perhaps marked with a label such as "later" or "punted".
That way we can try to keep the issue stack tidy and avoid creating new issues that will still be here in 7 years time.
Ah, just because it's too low-priority for me doesn't mean it will be too low-priority for the next volunteer who steps up. As you say, mmmv.
I wouldn't want to close this one without also closing the docs issue that spawned it. Also, this issue, which explicitly seeks to find out what kind of things such a ROAST test should prohibit, has only been open for a couple of months: not enough time for all knowledgeable parties to weigh in on that question.
Which, come to think of it, is another reason why I'm not eager to try to write a ROAST test for this right now: I'm not sufficiently knowledgeable to make that particular decision.
The "unit" scope will absorb any code as part of the that scope until the end of the file".
No reasons why we can't say that: it's true even without RakuAST if I understand correctly. The issue is about code that occurs before the unit scope begins.
This was discussed at the Resolutions meeting yesterday, and while I did speak up to say that I would close the associated docs issue as soon as this issue is resolved, I didn't volunteer to record the resolution that we reached, and honestly, I can't clearly recall what it was.
Okay, I need to clarify, because I'm a little surprised that I missed such a sweeping change being decided on at a meeting that I attended. (I have no objection to the change, but I guess the full extent wasn't clear to me at the time?)
My understanding is that the decision reached at the meeting is that, for 6.e, we plan to specify that
unit simply declares a single named scope for the rest of the compilation unit (file, string, etc), allowing the convenient reduction in indentation level, and
unit will no longer prohibit anything being declared before it.
The plan is to change any tests currently in roast to reflect this, and to remove the doc's current statement that the only things that can appear before a unit are comments and use statements.
@raiph , thanks. I have edited my comment accordingly.
I found the official announcement, which answers all my questions, but I'm leaving the comment up as a way of polling for anyone who is surprised by the decision and might object to it.
In the meantime I have updated the now-unblocked docs issue accordingly, so I'll know what to do when I get to writing that docs PR.
Activity
[-]What makes C<unit> be too late?[/-][+]What makes `unit` be too late?[/+]librasteve commentedon Oct 23, 2025
does this mean that
unitcannot be used withsub EXPORT-or- that you can declaresub EXPORTbefore theunitline?[not asking for ROAST info - just what do es hte latest rakudo do in practice]
arkiuat commentedon Oct 23, 2025
@librasteve, the original issue stated that you can in fact declare any number of subs before a unit package. I just tested declaring an empty
sub EXPORTfollowed by aunit packageand got no errorslibrasteve commentedon Oct 23, 2025
tx! so let's document that ;-)
arkiuat commentedon Oct 23, 2025
There was some discussion of that on the other issues linked above, and there's reluctance to document things that ROAST doesn't require, which makes sense, since all such behavior is technically implementation detail and not part of the language we're documenting.
Discussion to come to a consensus (about what ROAST should require here) got bogged down in the now-closed rakudo issue rakudo/rakudo#2020, which is why I opened this one, because lack of such consensus is what's blocking the docs issue Raku/doc#2148.
My own opinion about what the consensus seemed to be groping toward is that
sub EXPORTand the like should be allowed (like comments andusestatements) before aunitdeclaration, but that any sub not explicitly allowed there should be disallowed.By 'and the like' I mean any other ALL-CAPS subs clearly connected to the namespace in question (as
EXPORTis) but which for some reason have to live outside that namespace. This is intended to cover both future developments and also possibly other existing language features that I haven't learned about yet: the general principle is that there's an allowlist for this, and anything not on it would cause squawking.librasteve commentedon Oct 23, 2025
@arkiuat - I agree
arkiuat commentedon Dec 20, 2025
So should I be trying to write my first ROAST tests then? I think for this one, we want to add it to the spec before changing the doc.
arkiuat commentedon Dec 25, 2025
Not sure how helpful this is, but here's an old discussion of this issue from 2016, that is linked to from current doc.
librasteve commentedon Dec 27, 2025
@arkiuat - agree that adding to ROAST first is a good plan.
I have written (literally) a couple of ROAST tests - having seen you work in the docs, I am sure that you will find it straightforward (and of course there are many out there to help if you get stuck)
arkiuat commentedon Dec 28, 2025
@librasteve thanks, but it's not that I'm hesitant to submit a PR for ROAST, or even that I'm not sure how to test for this particular thing. It has just become clear to me that this isn't going to make it to the top of my priorities anytime soon, if ever.
At worst, the status quo is that anyone can add a
unitclass/module/package/whatever to the end of any file that doesn't define other classes/packages/etc, as long as it's the last thing in the file, but the docs say that you can't do this, perhaps in hopes of preventing people from making a habit of it. I'm okay with leaving that as is because there are bigger fish to fry, so I'll leave it for someone who cares about it more than I do.Originally I was just trying to knock off an old blocked docs issue, but the scope has creeped. We're just talking about a way to save a level of indentation here.
librasteve commentedon Dec 29, 2025
OK - thanks for explaining - we all have our various foci and time constraints.
On a matter of "issue etiquette" I personally prefer "issues that we know are real, but have no prospect of getting resourced since we consider them too low priority" be Closed (ie both this problem-solver and the referenced doc issue above), and perhaps marked with a label such as "later" or "punted".
That way we can try to keep the issue stack tidy and avoid creating new issues that will still be here in 7 years time.
ymmv ;-)
arkiuat commentedon Dec 29, 2025
Ah, just because it's too low-priority for me doesn't mean it will be too low-priority for the next volunteer who steps up. As you say, mmmv.
I wouldn't want to close this one without also closing the docs issue that spawned it. Also, this issue, which explicitly seeks to find out what kind of things such a ROAST test should prohibit, has only been open for a couple of months: not enough time for all knowledgeable parties to weigh in on that question.
Which, come to think of it, is another reason why I'm not eager to try to write a ROAST test for this right now: I'm not sufficiently knowledgeable to make that particular decision.
librasteve commentedon Dec 30, 2025
lol - ok, fair enough
lizmat commentedon Jan 8, 2026
This issue will be discussed in the first Raku Resolutions meeting, see more information at https://dev.to/lizmat/raku-resolutions-17g7
RakuAST: prevent execution error if no RakuAST
lizmat commentedon Jan 17, 2026
Looking at this a little more in depth, I don't see a reason (yet) why it shouldn't be possible to just say (at least in RakuAST):
The "unit" scope will absorb any code as part of the that scope until the end of the file".
Perhaps someone can point me to reasons why this shouldn't be the case?
arkiuat commentedon Jan 17, 2026
No reasons why we can't say that: it's true even without RakuAST if I understand correctly. The issue is about code that occurs before the
unitscope begins.lizmat commentedon Jan 17, 2026
True. I meant "regardless of any code before the
unitscope :-)arkiuat commentedon Feb 22, 2026
This was discussed at the Resolutions meeting yesterday, and while I did speak up to say that I would close the associated docs issue as soon as this issue is resolved, I didn't volunteer to record the resolution that we reached, and honestly, I can't clearly recall what it was.
lizmat commentedon Feb 22, 2026
In my recollection the conclusion was:
unitindicates a scope for the rest of the source (usually a file, but technically could also be a string being EVALled)unitstatement (but currently it does, to be fixed in 6.e).raiph commentedon Feb 23, 2026
arkiuat commentedon Feb 24, 2026
Okay, I need to clarify, because I'm a little surprised that I missed such a sweeping change being decided on at a meeting that I attended. (I have no objection to the change, but I guess the full extent wasn't clear to me at the time?)
My understanding is that the decision reached at the meeting is that, for 6.e, we plan to specify that
unitsimply declares a single named scope for the rest of the compilation unit (file, string, etc), allowing the convenient reduction in indentation level, andunitwill no longer prohibit anything being declared before it.The plan is to change any tests currently in roast to reflect this, and to remove the doc's current statement that the only things that can appear before a
unitare comments andusestatements.Does anyone have any objections to this?
raiph commentedon Feb 25, 2026
arkiuat commentedon Feb 25, 2026
@raiph , thanks. I have edited my comment accordingly.
I found the official announcement, which answers all my questions, but I'm leaving the comment up as a way of polling for anyone who is surprised by the decision and might object to it.
In the meantime I have updated the now-unblocked docs issue accordingly, so I'll know what to do when I get to writing that docs PR.
arkiuat commentedon Mar 8, 2026
The mention of the prohibition has been removed from the documentation, and docs issue 2148 has been closed.