Ticket #282 (new defect)

Opened 1 year ago

Last modified 1 year ago

Cleanup: Remove top-of-block restriction on "use" pragmas

Reported by: lth Assigned to: lth
Type: defect Priority: major
Milestone: Component: Spec
Version: 4 Keywords:
Cc: brendan,jeffdyer,graydon

Description

Proposal: remove the top-of-block restriction on all "use" pragmas. Allow them everywhere, and have their effect last from the point of the pragma to the end of the block.

Reason: It's a pain to have to introduce arbitrary blocks for namespaces. You end up with code like this:

   namespace ns
   {  // pointless block starts
      use namespace ns
      ...
   }  // pointless block ends

I seem to remember that I proposed the restriction previously. I think it was a mistake.

Attachments

Change History

Changed 1 year ago by lth

I think we should make this change for import pkg.x and import pkg.* also. For a discussion of import y = pkg.x, see #283.

Changed 1 year ago by brendan

Agreed, FWIW -- good to hear from Graydon and Jeff. IIRC Graydon has been cautioning that "the beginning of the top-level fragment" (or something like that) has no meaning, in that you can add more fragments and we want to allow pragmas in them.

/be

Changed 1 year ago by jeffdyer

I was one of the instigators of the rule and after writing lots of "pointless braces" I don't like it anymore. So I agree, allow pragmas anywhere a directive can occur and have it effect the meaning of code between it and the end of the current block.

Jd

Changed 1 year ago by lth

Discussion at Nov 27 phone meeting. We don't yet see the consequences of lifting the restriction. Jeff and Graydon will consider the case whether there is some primitive underlying packages that would allow packages to be desugared and which might shed light on how the current usability problem with "use"/"import" might be resolved.

Note: See TracTickets for help on using tickets.