RE: [sv-ec] Constant class methods

From: Mirek Forczek <mirekf_at_.....>
Date: Wed Apr 02 2008 - 07:16:50 PDT
OK, so let's re-define it:

'this' is a const handle to a dynamic object anyway (as for today),

Applying 'const' on method would imply that 'this' shall be treated as a
const handle to a constant dynamic object - within body range of that
method.

Than you cannot write to class properties of the 'this' object - from within
the const method. 

Mirek
 

-----Original Message-----
From: Rich, Dave [mailto:Dave_Rich@mentor.com] 
Sent: 2 kwietnia 2008 16:09
To: Mirek Forczek; Steven Sharp; sv-ec@server.eda.org; danielm@aldec.com.pl
Subject: RE: [sv-ec] Constant class methods

Hold on there. SV does not have static classes. The implicit "this"
argument to a method of a class is just a handle to a dynamic object.
Making "this" a const just prevents you from modifying the handle; you can
still write to class properties.

> -----Original Message-----
> From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org]
On
> Behalf Of Mirek Forczek
> Sent: Wednesday, April 02, 2008 1:57 AM
> To: 'Steven Sharp'; sv-ec@server.eda.org; danielm@aldec.com.pl
> Subject: RE: [sv-ec] Constant class methods
> 
> Indeed, having 'const' attribute on method would result in treating
the
> implicit 'this' argument as constant one. That's what would happen
within
> scope of the method body.
> 
> But the 'const' attribute on method would have also impact on
semantics
> outside the method body:
> 
> - clearly denote the method's nature (documentation),
> - provide semantics to allow (const) method calls in special contexts 
> (i.e.
> assertion formula),
> - provide input for compiler to enable potential code optimizations.
> 
> Regards,
> Mirek
> 
> -----Original Message-----
> From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org]
On
> Behalf Of Steven Sharp
> Sent: 2 kwietnia 2008 02:39
> To: sv-ec@server.eda.org; danielm@aldec.com.pl
> Subject: Re: [sv-ec] Constant class methods
> 
> 
> >From: "danielm" <danielm@aldec.com.pl>
> 
> >IMHO SV should itroduce constant modifier to class methods
(functions,
> >and task). This feature is widely used in other languages - ie in
C++.
> >Such modifier should forbid to modify class properties referenced.
> >It would be very usefull to know that certain function do not
modifies
> >the object on which it is called.
> 
> Is this equivalent to treating the implicit 'this' argument as const?
> 
> Steven Sharp
> sharp@cadence.com
> 
> 
> --
> This message has been scanned for viruses and dangerous content by 
> MailScanner, and is believed to be clean.
> 
> 
> --
> This message has been scanned for viruses and dangerous content by 
> MailScanner, and is believed to be clean.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Apr 2 07:21:50 2008

This archive was generated by hypermail 2.1.8 : Wed Apr 02 2008 - 07:22:20 PDT