Re: Another feature request

From: Marco Caspers (*nospam*_at_haxor.vaxor.com)
Date: 12/16/03


Date: 16 Dec 2003 00:36:49 -0700

Andrew Rybenkov wrote:

> Add "TypeOf" compiler (pseudo-)function (like "SizeOf") to use in
> declarations:
>
> var
> n: <sometype>;
>
> ...
>
> var
> m: TypeOf(n);

What's the purpose?

You will have to know the type of <sometype> else you can not do
anything with M,

You woudn't not know how to handle it.

Imagine the bugs.

For example:

Var
  n: ^MyRecord;

Function MyFunction: String
Var
  m: TypeOf(n);
Begin
  m := m + 'This is a string that can not be added to a pointer';
  Result := m;
End;

Normally you wouldn't be able to compile it.

With your construct you probably could, and are faced with a bug in
your application that'd only show up at runtime. Just like all the
unsafe typecasting in an other programming language.

This one will be fairly easy to spot if you have the source code where
n is decleared..
If you don't have the source then you're fried and would probably never
find the 'why' of the bug, especially if it's hidden under a heap of
if/then/else constructions that only occurs under difficult to
replicate conditions..

Regards,
Marco.



Relevant Pages

  • TransModal modal dialog project : beta testing
    ... I am proposing the current v. 0.0.3 beta for criticism and for bug fix ... user's preferred language and not English ... var lang = navigator.userLanguage.substring; ... * Until IE7 form controls were external DirectX objects ...
    (comp.lang.javascript)
  • Re: undefined vs. undefined (was: new Array() vs [])
    ... After thinking it over again tonight, I see no bug in Mozilla. ... Quote 1 ... Elided array elements are not defined. ... var p = br + br; ...
    (comp.lang.javascript)
  • [Full-disclosure] Re: IE_ONE_MINOR_ONE_MAJOR
    ... Plebo Aesdi Nael wrote about an IE bug with outerHTML. ... works only on a small number of sites that use that header.) ... var stop=0 ...
    (Full-Disclosure)
  • Re: Possible bug in gosub vars
    ... but I still would consider it to be a bug since the back ticks ... It is a bug in 4DOS only, present in the last build that had been ... It was there before 4DOS went into the public domain, before Lucho ...
    (comp.os.msdos.4dos)
  • Re: Statement limit bug
    ... my primary suspicion remains that everyone used "lazy test" with forloops which is all another problem irrelevant to statements' limit. ... It has already been confirmed as a bug by at least 3 people. ... Did you fail to comprehend this thread? ... var x=3; ...
    (microsoft.public.scripting.jscript)