Issue Details (XML | Word | Printable)

Key: BOO-1115
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Cedric Vivier
Reporter: Cedric Vivier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Strict mode

Created: 16/Jan/09 08:57 PM   Updated: 29/Jan/09 01:23 AM   Resolved: 23/Jan/09 02:10 PM
Return to search
Component/s: Compiler
Affects Version/s: 0.8.2
Fix Version/s: 0.9

Time Tracking:
Not Specified

Issue Links:
Related
 
Supercedes
 
dependent
 


 Description  « Hide

Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:

  • "-strict" with booc
  • programatically by setting CompilerParameters.Strict to true
  • "strict" argument with nant and msbuild tasks

When strict mode is enabled the following changes are enabled:

  • default visibility is private like in C# (change made through BOO-1091)
  • methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage] (BOO-1132)
  • warns if a variable has the same name as a private field of one of its super types (BOO-1133).
  • implicit return statement fires a warning (BOO-703)

TODO:

  • implicit downcast fires a warning (BOO-943) — default mode? or strict mode only?


Cedric Vivier made changes - 16/Jan/09 08:58 PM
Field Original Value New Value
Link This issue supercedes BOO-943 [ BOO-943 ]
Cedric Vivier made changes - 16/Jan/09 08:58 PM
Link This issue supercedes BOO-1092 [ BOO-1092 ]
Cedric Vivier made changes - 16/Jan/09 08:58 PM
Link This issue relates to BOO-1091 [ BOO-1091 ]
Cedric Vivier made changes - 16/Jan/09 08:59 PM
Link This issue relates to BOO-1091 [ BOO-1091 ]
Cedric Vivier made changes - 16/Jan/09 08:59 PM
Link This issue depends upon BOO-1091 [ BOO-1091 ]
Cedric Vivier made changes - 16/Jan/09 09:04 PM
Description For a number of Boo users, sometimes Boo is not conservative enough on certain defaults (which makes sense for others) that can make some errors slip through a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
Compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
Cedric Vivier made changes - 16/Jan/09 09:23 PM
Link This issue is related to BOO-692 [ BOO-692 ]
Cedric Vivier added a comment - 16/Jan/09 09:25 PM

BOO-703 is also worth considering for strict mode imo.


Cedric Vivier made changes - 16/Jan/09 09:26 PM
Link This issue depends upon BOO-703 [ BOO-703 ]
Cedric Vivier made changes - 16/Jan/09 09:27 PM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
- implicit return statement fires a warning (BOO-703)
Cedric Vivier made changes - 16/Jan/09 09:29 PM
Link This issue is related to BOO-1087 [ BOO-1087 ]
Cedric Vivier made changes - 16/Jan/09 09:39 PM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
- implicit return statement fires a warning (BOO-703)
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks

In effect, it adds a StrictModeCheckingStep into the pipeline.


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
- implicit return statement fires a warning (BOO-703)
Cedric Vivier made changes - 17/Jan/09 12:31 AM
Status Open [ 1 ] In Progress [ 3 ]
Rodrigo B. de Oliveira added a comment - 17/Jan/09 07:09 AM

Field naming convention doesn't seem to belong in there.

BOO-703 seems to.


Cedric Vivier added a comment - 17/Jan/09 07:21 AM - edited

I was expecting this about the field naming

On the other hand, it is necessary to have something to guarantee no silent behavior-change wrt conflicts between fields and variables don't you agree?
As far as I see, either we'd do like python and require "self." for field references, either we'd have to add a keyword for explicit variable declaration.
Both options would make enabling strict mode source-breaking and less useful in general (since all existing code would require change)

Since we recommended this naming from the start and that most existing code do follow this rule afaik, don't you think considering "_"-prefix, not much a naming issue but more of a "explicit field reference" is a good compromise?
Of course this rule would apply only to internal field definitions (and ignore uppercased static/final fields).


Cedric Vivier added a comment - 17/Jan/09 07:32 AM

Hmm another mostly non-breaking option that would not require preferring one 'recommended naming' among others:

In strict-mode, disallow to name a variable the same as a field of the declaring type (or one of its super types)

What do you think of this one?


Rodrigo B. de Oliveira made changes - 22/Jan/09 09:24 AM
Fix Version/s 0.9 [ 13816 ]
Fix Version/s 0.9.1 [ 14922 ]
Cedric Vivier made changes - 23/Jan/09 03:04 AM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks

In effect, it adds a StrictModeCheckingStep into the pipeline.


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type must be explicitely declared
- field naming recommendations are enforced (ie. _-prefix on non-visible fields), this enforces consistency and ensure no unnoticed conflict/behavior-change with variables which have same name than a field.
- implicit downcast fires a warning (BOO-943)
- implicit return statement fires a warning (BOO-703)
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks

In effect, it adds a StrictModeCheckingStep into the pipeline.


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage]
- warns if a variable cannot have the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Cedric Vivier made changes - 23/Jan/09 03:07 AM
Fix Version/s 0.9.1 [ 14922 ]
Fix Version/s 0.9 [ 13816 ]
Cedric Vivier added a comment - 23/Jan/09 03:16 AM

Partially landed in rev.3172
"strict" option added to booc and nant, only changes default visibility for now (other features to follow)


Cedric Vivier made changes - 23/Jan/09 07:26 AM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Introducing a strict mode would be a nice new feature to introduce and enforce more conservative(safer) defaults if desired.

Strict mode is disabled by default.
This compiler option would be settable through:
- "-strict+" on booc
- CompilerParameters.Strict as bool
- "strict" argument in nant and msbuild tasks

In effect, it adds a StrictModeCheckingStep into the pipeline.


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage]
- warns if a variable cannot have the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:
- "-strict" with booc
- programatically by setting CompilerParameters.Strict to true
- "strict" argument with nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage]
- warns if a variable has the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

TODO:
- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Cedric Vivier added a comment - 23/Jan/09 08:37 AM

BOO-703 is in.


Cedric Vivier made changes - 23/Jan/09 10:45 AM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:
- "-strict" with booc
- programatically by setting CompilerParameters.Strict to true
- "strict" argument with nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage]
- warns if a variable has the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

TODO:
- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:
- "-strict" with booc
- programatically by setting CompilerParameters.Strict to true
- "strict" argument with nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage] (BOO-1132)
- warns if a variable has the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

TODO:
- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Cedric Vivier made changes - 23/Jan/09 10:46 AM
Link This issue depends upon BOO-1132 [ BOO-1132 ]
Cedric Vivier added a comment - 23/Jan/09 10:54 AM

BOO-1132 is in.


Cedric Vivier made changes - 23/Jan/09 11:05 AM
Description Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:
- "-strict" with booc
- programatically by setting CompilerParameters.Strict to true
- "strict" argument with nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage] (BOO-1132)
- warns if a variable has the same name as a field of its declaring type (or one of its super types).
- implicit return statement fires a warning (BOO-703)

TODO:
- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Sometimes Boo is not conservative enough on certain defaults (which still makes sense for other/prototyping usages) that can lead to some errors slipping to a release unnoticed in (large) projects.

Strict mode introduces more conservative(safer) defaults and warnings.
Strict mode is disabled by default.

This compiler option is settable through:
- "-strict" with booc
- programatically by setting CompilerParameters.Strict to true
- "strict" argument with nant and msbuild tasks


When strict mode is enabled the following changes are enabled:
- default visibility is private like in C# (change made through BOO-1091)
- methods parameters types and return type of public methods (API) must be explicitely declared [to avoid unnoticed/unwanted binary-compat breakage] (BOO-1132)
- warns if a variable has the same name as a private field of one of its super types (BOO-1133).
- implicit return statement fires a warning (BOO-703)

TODO:
- implicit downcast fires a warning (BOO-943) --- default mode? or strict mode only?
Cedric Vivier made changes - 23/Jan/09 11:06 AM
Link This issue depends upon BOO-1133 [ BOO-1133 ]
Cedric Vivier made changes - 23/Jan/09 02:10 PM
Resolution Fixed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
David Piepgrass added a comment - 28/Jan/09 06:25 PM

I would definitely like a warning for implicit downcasts and implicit return values, but at the same time I strongly prefer inferred return types and default-public access for methods.

Rationale: implicit downcasts and implicit null return values let you shoot yourself in the foot, whereas return type inference and default-public access are low-risk, oft-used features that are essential to boo's wrist-friendliness. I can see how changing return types affects binary compatibility, but I submit that most developers only need binary compatibility guarantees in a small subset of the code they write.

Shouldn't this feature be more fine-grained?


Cedric Vivier added a comment - 29/Jan/09 01:18 AM - edited

I would definitely like a warning for implicit downcasts and implicit return values, but at the same time I strongly prefer inferred return types and default-public access for methods.

The warning about inferred return types and parameters types is for API (ie. visible) methods only, by default you do not get this warning since by default all methods are private.
The rationale about this is that as one should try to pick and publicize only methods that are meant to be used from outside, be easier to document to both team and third-party, and more importantly these methods must not change 'without notice' (like it can with slight changes with inference) since it breaks binary-compatibility.

only need binary compatibility guarantees in a small subset of the code they write.

I agree on the large idea (small subset need guarantee) but I disagree with your conclusion, if default method access is public then you probably publish without noticing an unwanted API that is far larger than the "small subset" you intend(ed) to guarantee.
Also since indeed you generally publicize a small subset only, it makes the 'non-wristfriendliness' to add 'public' to intended public methods and their types less of a burden.

Shouldn't this feature be more fine-grained?

It can
Just use:

with booc:

-nowarn:BCW0024 -define:DEFAULT_METHOD_VISIBILITY=public

with nant:

<booc ....strict="true" define="DEFAULT_METHOD_VISIBILITY=public">
<nowarn>
     <include>BCW0024</include>
</nowarn>

or in code:

import Boo.Lang.Compiler
macro compilerSettings:
     Parameters.DisableWarning("BCW0024")
     Parameters.DefaultMethodVisibility = TypeMemberModifiers.Public

Alternatively, if strict mode is too strict for your taste, you can just enable BCW0023 (implicit return statement) since it seems that is the only thing that you care about.