[AccessD] explicit type

John Colby jcolby at colbyconsulting.com
Thu Oct 2 12:35:54 CDT 2003


No, constants are not dynamic however AFAIK if you don't state their type,
then they are created using a variant.  That variant can be passed to an
integer or a string or a date or a currency.  Thus you could cause type
conversions that were unintended by passing the constant to a function (for
example).  If the constant is currency stored as a string, you cannot pass
it to a currency variable without specifically typecasting it.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Thursday, October 02, 2003 12:37 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] explicit type


I agree on the speed issue and variants, but we are talking about
constants, not variables, and constants are not dynamic.  Since the
programmer has to populate the constant and logically does so when
he/she creates the thing, is it really likely they will assign the wrong
kind of data to it?

Charlotte Foust

-----Original Message-----
From: John Colby [mailto:jcolby at colbyconsulting.com]
Sent: Thursday, October 02, 2003 8:11 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] explicit type


Charlotte,

>Since constants can't be changed, it doesn't seem terribly wrong to
>skip
typing them.

One of the reasons for even having typed data is to prevent
inadvertently assigning the data to a variable of the wrong type.  If
you don't type a constant, AFAIK it ends up a variant.  Variants are
horribly slow, and can cause (or allow) coercion to a different data
type etc.  By stating that "this constant is a string", or "this
constant is a currency", you prevent programming bugs creeping in.  And
then there is the speed issue of using variants, memory storage of the
variant etc.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Thursday, October 02, 2003 11:48 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] explicit type


I generally type my constants, but I think it is unusual in printed code
for the same reason that error handling is often left out.  Since
constants can't be changed, it doesn't seem terribly wrong to skip
typing them.

Charlotte Foust

-----Original Message-----
From: John B. [mailto:john at winhaven.net]
Sent: Thursday, October 02, 2003 6:51 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] explicit type

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list