Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not need '!' for accessing compile-time properties of a field #14705

Open
vasslitvinov opened this issue Jan 2, 2020 · 2 comments
Open

Comments

@vasslitvinov
Copy link
Member

vasslitvinov commented Jan 2, 2020

This is a more complex pattern than #13617.

When accessing a field of a nilable class, the postfix-! operator should not be required when the use of the field is limited to compile-time operations. This is for convenience.

For example, none of the !s in this code should be required, as there should be no runtime nil checks. It is more convenient to omit them.

class C1 {
  var x: int;
  var y;     // a generic field
}

class C2 {
  param p;
  type t;
}

var c: owned C1(owned C2(5,int)?)?;

// the type of a field
writeln(c!.x.type:string, c!.y.type:string);

// type, param queries on the class pointed to by a field
writeln(c!.y.p:string, c!.y.t:string);

Example test:

# see proc getSuperType()
test/classes/diten/nearestMutualParentClass.chpl
@bradcray
Copy link
Member

bradcray commented Jun 4, 2020

@vasslitvinov: I have a vague memory from the CHANGES file that you implemented this, is that right? Can it be closed?

@vasslitvinov
Copy link
Member Author

Good point. My implementation resolved #13617. The examples in this issue are more complex than that and currently still require !.

So no, this issue is not resolved yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants