jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Boo
  • Boo
  • BOO-1115

Strict mode

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.8.2
  • Fix Version/s: 0.9
  • Component/s: Compiler
  • Labels:
    None
  • Number of attachments :
    0

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 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?

Issue Links

depends upon

New Feature - A new feature of the product, which has yet to be developed. BOO-1091 Possibility to change default visibility settings

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

New Feature - A new feature of the product, which has yet to be developed. BOO-1132 WARNING: Visible method|property does not declare return|argument type explicitely

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

New Feature - A new feature of the product, which has yet to be developed. BOO-1133 WARNING: Variable 'X' has the same name as a field of base type 'T'. Did you mean to use the field ?

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Improvement - An improvement or enhancement to an existing feature or task. BOO-703 Compiler warning on implicit return statement

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.
is related to

Bug - A problem which impairs or prevents the functions of the product. BOO-1087 Compiler should warn when an implicit callable is used in a boolean context

  • Major - Major loss of function.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Bug - A problem which impairs or prevents the functions of the product. BOO-692 Built-in value type conversions

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
supercedes

Improvement - An improvement or enhancement to an existing feature or task. BOO-1092 Change default field visibility from protected to private

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Wish - General wishlist item BOO-943 Implicit downcast in strict mode

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.
Show 3 more links (1 is related to, 2 supercedes)

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Cedric Vivier added a comment - 16/Jan/09 9:25 PM

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

Show
Cedric Vivier added a comment - 16/Jan/09 9:25 PM BOO-703 is also worth considering for strict mode imo.
Hide
Permalink
Rodrigo B. de Oliveira added a comment - 17/Jan/09 7:09 AM

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

BOO-703 seems to.

Show
Rodrigo B. de Oliveira added a comment - 17/Jan/09 7:09 AM Field naming convention doesn't seem to belong in there. BOO-703 seems to.
Hide
Permalink
Cedric Vivier added a comment - 17/Jan/09 7: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).

Show
Cedric Vivier added a comment - 17/Jan/09 7: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).
Hide
Permalink
Cedric Vivier added a comment - 17/Jan/09 7: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?

Show
Cedric Vivier added a comment - 17/Jan/09 7: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?
Hide
Permalink
Cedric Vivier added a comment - 23/Jan/09 3:16 AM

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

Show
Cedric Vivier added a comment - 23/Jan/09 3:16 AM Partially landed in rev.3172 "strict" option added to booc and nant, only changes default visibility for now (other features to follow)
Hide
Permalink
Cedric Vivier added a comment - 23/Jan/09 8:37 AM

BOO-703 is in.

Show
Cedric Vivier added a comment - 23/Jan/09 8:37 AM BOO-703 is in.
Hide
Permalink
Cedric Vivier added a comment - 23/Jan/09 10:54 AM

BOO-1132 is in.

Show
Cedric Vivier added a comment - 23/Jan/09 10:54 AM BOO-1132 is in.
Hide
Permalink
David Piepgrass added a comment - 28/Jan/09 6: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?

Show
David Piepgrass added a comment - 28/Jan/09 6: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?
Hide
Permalink
Cedric Vivier added a comment - 29/Jan/09 1: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.

Show
Cedric Vivier added a comment - 29/Jan/09 1: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.

People

  • Assignee:
    Cedric Vivier
    Reporter:
    Cedric Vivier
Vote (0)
Watch (0)

Dates

  • Created:
    16/Jan/09 8:57 PM
    Updated:
    29/Jan/09 1:23 AM
    Resolved:
    23/Jan/09 2:10 PM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.