November 07, 2001 some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
There are some things there that just aren't clear enough... Complex arrays. Judging by the specs, int[]* is a pointer to array, int*[] is an array of pointers. Is int[]*[] a legal way to declare an array of pointers to arrays? Is int*[]* a legal way to declare a pointer to array of pointers? Static attribute. Are static local variables supported? Array slicing. What happens when I use the form a[x..y], and x is greater than y? Class model. It says that for each class XXXX, an instance of Class is created, named ClassXXXX. What is Class (RTTI, I believe), what functionality it provides? If I have a reference to object, how do I get the appropriate Class object? Is it possible to construct an object without knowing its type at compile-time, via its Class (like in Delphi)? Distinguishing between . and -> It is stated that there is no need for -> in D, since it's clear to the compiler whether we access fields directly or through pointer. But specification contains the following definition: PostfixExpression: PrimaryExpression PostfixExpression . Identifier PostfixExpression -> Identifier (!?) A mistake? Methods of base class. How do I access them? I believe that super.method form is used to call methods of super class. But how to call a method of an arbitrary class in the hierarchy - super(class).method? Static methods. Can they be overridden? Can they be called in the same manner as non-static ones? Modules. According to specification, "Modules have a one- to-one correspondence with source files. The module name is the file name with the path and extension stripped off." Does this mean that module names are case-insensitive on Windows and case-sensitive on *nix? If not, how is it achieved? ... to be continued ... =) |
November 08, 2001 Re: some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | "Pavel "EvilOne" Minayev" <evilone@omen.ru> wrote in message news:9sb0c1$ceq$1@digitaldaemon.com... > Complex arrays. Judging by the specs, int[]* is a > pointer to array, int*[] is an array of pointers. > Is int[]*[] a legal way to declare an array of > pointers to arrays? Is int*[]* a legal way to > declare a pointer to array of pointers? Yes, yes! > Static attribute. Are static local variables > supported? Yes. > Array slicing. What happens when I use the form > a[x..y], and x is greater than y? If you have array bounds checking turned on, an array bounds exception gets thrown. > Class model. It says that for each class XXXX, an > instance of Class is created, named ClassXXXX. What > is Class (RTTI, I believe), what functionality it > provides? A way to examine the type and offset of each member, access to the finalizer, and (in the future) access to any classes it depends on. > If I have a reference to object, how > do I get the appropriate Class object? There's a member function to get it. Or a property. I can't decide which <g>. > Is it possible > to construct an object without knowing its type > at compile-time, via its Class (like in Delphi)? That sounds like a good idea. > Distinguishing between . and -> > It is stated that there is no need for -> in D, since > it's clear to the compiler whether we access fields > directly or through pointer. But specification contains > the following definition: > > PostfixExpression: > PrimaryExpression > PostfixExpression . Identifier > PostfixExpression -> Identifier (!?) > > A mistake? Yes. > Methods of base class. How do I access them? I believe > that super.method form is used to call methods of super > class. But how to call a method of an arbitrary class > in the hierarchy - super(class).method? If class B is derived from A, you can also use: B b; b.A.foo(); > Static methods. Can they be overridden? Can they be > called in the same manner as non-static ones? Yes, yes. > Modules. According to specification, "Modules have a one- > to-one correspondence with source files. The module name > is the file name with the path and extension stripped off." > Does this mean that module names are case-insensitive on > Windows and case-sensitive on *nix? If not, how is it > achieved? Module names are case sensitive. On windows, this means that you cannot have two modules that differ only in case. While not elegant, I doubt it will be a significant problem in practice. > ... to be continued ... =) Great questions! |
November 08, 2001 Re: some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:9sdc1v$2167$1@digitaldaemon.com... > > Array slicing. What happens when I use the form > > a[x..y], and x is greater than y? > > If you have array bounds checking turned on, an array bounds exception gets > thrown. And if not? I mean, since the copying code will, in general, be the loop (or am I wrong?), it simply won't do anything. > > Class model. It says that for each class XXXX, an > > instance of Class is created, named ClassXXXX. What > > is Class (RTTI, I believe), what functionality it > > provides? > > A way to examine the type and offset of each member, access to the finalizer, and (in the future) access to any classes it depends on. Ability to call methods of class by their name (a la IDispatch::Invoke)? Also, if those Class objects are unused, will they still be there (thus cluttering the program with unnecessary info like class and method names)? > > If I have a reference to object, how > > do I get the appropriate Class object? > > There's a member function to get it. Or a property. I can't decide which <g>. object.class, probably? > > Is it possible > > to construct an object without knowing its type > > at compile-time, via its Class (like in Delphi)? > > That sounds like a good idea. This, however, involves things like virtual constructors. > > Methods of base class. How do I access them? I believe > > that super.method form is used to call methods of super > > class. But how to call a method of an arbitrary class > > in the hierarchy - super(class).method? > > If class B is derived from A, you can also use: > > B b; > b.A.foo(); So, from withing B, I'd simply write: A.foo(); > > Static methods. Can they be overridden? Can they be > > called in the same manner as non-static ones? > > Yes, yes. So the following: class A { static void B() { ... } } A a; A::B(); a.B(); // the same? is legal? If it is, will B() be aware that it is called in a different way? |
November 08, 2001 some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | > ... to be continued ... =)
Here are some more:
What is the default attribute for class members
(private/protected/public)?
Suppose I have the following declaration:
int* x, y;
Is y an int or a pointer to int?
Once again, suppose there's a piece of code like that:
void X() { ... }
class B
{
void Y() { ... }
}
class C
{
void Y() { ... }
}
class A: B
{
void X() { ... }
void Y()
{
C B;
B.Y();
X();
}
}
Question #1: how do I call the global X() from A.Y() (since
simply typing X() would invoke A.X())?
Question #2: how do I access method Y() of class B from A.Y()
(since B.Y() will invoke method Y() of object C)?
... to be continued ... =)
|
November 08, 2001 technical question | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | What is the default calling convention for D functions - cdecl, stdcall, pascal, fastcall? BTW I wonder why you define stdcall convention as extern(Windows)? It's not WinAPI-only, there are stdcall specifiers in C, C++ and Pascal, and I believe that most programmers know it as stdcall. And in general, although convention is not a keyword, as stated in the specs, it looks like that, so - IMHO - it should be in lower-case. The same for extern(Pascal) - extern(pascal) seems to look better and more familiar especially to those who, like me, are used to Borland's compilers. |
November 08, 2001 Re: technical question | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | Don't you find it the least bit presumptuous to make a calling convention used only by Windows that is called "stdcall"? If there were such a thing as an industry standard, I guess that's it, a de facto one, I guess naming it stdcall probably helped. ;) I'm not sure a language spec should define platform-specific runtime behavior; the programs should (in theory) be agnostic to the choice of platform. If you're curious as to Walter's first D compiler's default for the initial platform, Windows... well that seems to be a valid question. Sean "Pavel "EvilOne" Minayev" <evilone@omen.ru> wrote in message news:9sdiqf$2721$1@digitaldaemon.com... > What is the default calling convention for D functions - cdecl, stdcall, pascal, fastcall? > > > BTW I wonder why you define stdcall convention as > extern(Windows)? It's not WinAPI-only, there are > stdcall specifiers in C, C++ and Pascal, and I believe > that most programmers know it as stdcall. And in > general, although convention is not a keyword, as > stated in the specs, it looks like that, so - IMHO - > it should be in lower-case. The same for extern(Pascal) - > extern(pascal) seems to look better and more familiar > especially to those who, like me, are used to Borland's > compilers. |
November 08, 2001 Re: some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | In article <9sb0c1$ceq$1@digitaldaemon.com>, "Pavel \EvilOne\ Minayev" <evilone@omen.ru> wrote: > Static attribute. Are static local variables supported? If you have public and private (etc.) attributes, you no longer appear to need static to make items private to a module. Of course, you still need them in functions and classes, but is there any other requirement for them at the top-level? (Especially for functions.) |
November 08, 2001 Re: some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Cohen | "Ben Cohen" <bc@skygate.co.uk> wrote in message news:9sdsmg$2dca$1@digitaldaemon.com... > > Static attribute. Are static local variables supported? ^^^^^ LOL =) > If you have public and private (etc.) attributes, you no longer appear to need static to make items private to a module. Of course, you still need them in functions and classes, but is there any other requirement for them at the top-level? (Especially for functions.) |
November 08, 2001 Re: technical question | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <spalmer@iname.com> wrote in message news:9sdpc1$2b9f$1@digitaldaemon.com... > Don't you find it the least bit presumptuous to make a calling convention used only by Windows that is called "stdcall"? If there were such a thing as an industry standard, I guess that's it, a de facto one, I guess naming it stdcall probably helped. ;) Yes, I know that it isn't actually "std". But it is well known as such, why rename? > I'm not sure a language spec should define platform-specific runtime behavior; the programs should (in theory) be agnostic to the choice of platform. If you're curious as to Walter's first D compiler's default for the initial platform, Windows... well that seems to be a valid question. If compiler is to be of any use on Windows, it has to support at least stdcall in any way. BTW specs don't define any calling conventions other than C and D, so support for stdcall and pascal is purely implementation- dependent. |
November 08, 2001 Re: some questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel \"EvilOne\" Minayev | Pavel \"EvilOne\" Minayev wrote: > And if not? I mean, since the copying code will, in general, be the loop (or am I wrong?), it simply won't do anything. The copying code isn't the problem. It's the allocation code. Presumably, the compiler views all indices as unsigned values. Similarly, the size parameter in the compiler equivalent of malloc() is unsigned. So take 1-3, with both numbers viewed as (perhaps) unsigned 32 bit ints, what do you get? IIRC, something near 4 billion elements. So the compiler tries to allocate 4 billion elements * x bytes per element = many many many bytes. In most architectures, this ends up throwing an OutOfMemory exception. But in some...where you have access to multiple GB of virtual memory...we consume an unbelievable quantity of memory. :( -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] |
Copyright © 1999-2021 by the D Language Foundation