Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 22, 2004 Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Many programmers loathe to document their code. When looking at undocumented C++ code, it's easy enough to open up a header file to get a good idea of what a class does and how it works. Though, it's not so easy in D. Sun Java (which also has no header files, for the Java impaired) has the javap program, which allows you to take a peek into classes, and is a handy way to get the interface and even private methods and variables.
Has anyone written a parser to dump the interface of a D class?
--
- Mik Mifflin
|
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | In .net is even better, assemblies (.exe, .dll) have metadata about the types (including comments about those properties/methods (xml documentation)) (just like in mp3s). And you can look at those super easy, there are apps for that. On Sat, 21 Feb 2004 19:56:19 -0500, Mik Mifflin <mik42@NOadelphiaSPAM.net> wrote: > Many programmers loathe to document their code. When looking at > undocumented C++ code, it's easy enough to open up a header file to get a > good idea of what a class does and how it works. Though, it's not so easy > in D. Sun Java (which also has no header files, for the Java impaired) has > the javap program, which allows you to take a peek into classes, and is a > handy way to get the interface and even private methods and variables. > > Has anyone written a parser to dump the interface of a D class? > -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to SpookyET | SpookyET wrote: > In .net is even better, assemblies (.exe, .dll) have metadata about the > types (including comments about those properties/methods (xml > documentation)) (just like in mp3s). And you can look at those super easy, > there are apps for that. > > On Sat, 21 Feb 2004 19:56:19 -0500, Mik Mifflin <mik42@NOadelphiaSPAM.net> wrote: > >> Many programmers loathe to document their code. When looking at >> undocumented C++ code, it's easy enough to open up a header file to get a >> good idea of what a class does and how it works. Though, it's not so >> easy >> in D. Sun Java (which also has no header files, for the Java impaired) >> has >> the javap program, which allows you to take a peek into classes, and is a >> handy way to get the interface and even private methods and variables. >> >> Has anyone written a parser to dump the interface of a D class? >> > > > I thought we just went over this... D is not .net -- - Mik Mifflin |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | All I'm saying is take the good features of .NET/C#. But you seem to be closed minded. On Sat, 21 Feb 2004 20:19:11 -0500, Mik Mifflin <mik42@NOadelphiaSPAM.net> wrote: > SpookyET wrote: > >> In .net is even better, assemblies (.exe, .dll) have metadata about the >> types (including comments about those properties/methods (xml >> documentation)) (just like in mp3s). And you can look at those super easy, >> there are apps for that. >> >> On Sat, 21 Feb 2004 19:56:19 -0500, Mik Mifflin <mik42@NOadelphiaSPAM.net> >> wrote: >> >>> Many programmers loathe to document their code. When looking at >>> undocumented C++ code, it's easy enough to open up a header file to get a >>> good idea of what a class does and how it works. Though, it's not so >>> easy >>> in D. Sun Java (which also has no header files, for the Java impaired) >>> has >>> the javap program, which allows you to take a peek into classes, and is a >>> handy way to get the interface and even private methods and variables. >>> >>> Has anyone written a parser to dump the interface of a D class? >>> >> >> >> > > I thought we just went over this... D is not .net > -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | "Mik Mifflin" <mik42@NOadelphiaSPAM.net> wrote in message news:c18unj$7fq$1@digitaldaemon.com... | Many programmers loathe to document their code. When looking at | undocumented C++ code, it's easy enough to open up a header file to get a | good idea of what a class does and how it works. Though, it's not so easy | in D. Sun Java (which also has no header files, for the Java impaired) has | the javap program, which allows you to take a peek into classes, and is a | handy way to get the interface and even private methods and variables. | | Has anyone written a parser to dump the interface of a D class? I don't think so. This would be a good spot to have a D grammar available. At least one that could parse declarations. Note javap works on class files, not source files, so I'm not too clear on what you are asking for: to strip out declarations from D source or to disassemble some compiled code to get the original D source. While programmers might be loathe to document code they sure should document APIs - otherwise no-one will want to use it. -Ben |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:c191js$dsn$1@digitaldaemon.com... > "Mik Mifflin" <mik42@NOadelphiaSPAM.net> wrote in message > news:c18unj$7fq$1@digitaldaemon.com... > | Many programmers loathe to document their code. When looking at > | undocumented C++ code, it's easy enough to open up a header file to get a > | good idea of what a class does and how it works. Though, it's not so easy > | in D. Sun Java (which also has no header files, for the Java impaired) has > | the javap program, which allows you to take a peek into classes, and is a > | handy way to get the interface and even private methods and variables. > | > | Has anyone written a parser to dump the interface of a D class? > > I don't think so. This would be a good spot to have a D grammar available. At least one that could parse declarations. > > Note javap works on class files, not source files, so I'm not too clear on what you are asking for: to strip out declarations from D source or to disassemble some compiled code to get the original D source. > > While programmers might be loathe to document code they sure should document APIs - otherwise no-one will want to use it. There's no practical way to disassemble object files into declarations. But D does offer an avenue for automated documentation that C# and Java do not have - Design by Contract. For example, instead of: // Input: s is 'a' or 'b' void foo(char s); we have: void foo(char s) in { assert(s == 'a' || s == 'b'); } This works better because comments are invariably out of date, wrong, incomplete, or missing. There's no ambiguity in the contract, and since it gets executed, it is guaranteed correct. |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote: > Note javap works on class files, not source files, so I'm not too clear on what you are asking for: to strip out declarations from D source or to disassemble some compiled code to get the original D source. > > While programmers might be loathe to document code they sure should document APIs - otherwise no-one will want to use it. > > -Ben Sorry, I should have made myself more clear. I was looking for a program to parse d source and dump out the public methods and variables of classes. I haven't written a parser in a long while, but to write a small parser to recognize classes and public identifiers wouldn't be too difficult, if I understand correctly. So.. I take it no program exists yet? -- - Mik Mifflin |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:c191js$dsn$1@digitaldaemon.com... > "Mik Mifflin" <mik42@NOadelphiaSPAM.net> wrote in message > news:c18unj$7fq$1@digitaldaemon.com... > | Many programmers loathe to document their code. When looking at > | undocumented C++ code, it's easy enough to open up a header file to get a > | good idea of what a class does and how it works. Though, it's not so easy > | in D. Sun Java (which also has no header files, for the Java impaired) has > | the javap program, which allows you to take a peek into classes, and is a > | handy way to get the interface and even private methods and variables. > | > | Has anyone written a parser to dump the interface of a D class? > > I don't think so. This would be a good spot to have a D grammar available. At least one that could parse declarations. > > Note javap works on class files, not source files, so I'm not too clear on what you are asking for: to strip out declarations from D source or to disassemble some compiled code to get the original D source. > > While programmers might be loathe to document code they sure should document APIs - otherwise no-one will want to use it. Quite true. If the code itself doesn't have the minimum - a la Doxygen or JavaDoc - then it's not worth using. QED |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:c191js$dsn$1@digitaldaemon.com... > > "Mik Mifflin" <mik42@NOadelphiaSPAM.net> wrote in message > > news:c18unj$7fq$1@digitaldaemon.com... > > | Many programmers loathe to document their code. When looking at > > | undocumented C++ code, it's easy enough to open up a header file to get > a > > | good idea of what a class does and how it works. Though, it's not so > easy > > | in D. Sun Java (which also has no header files, for the Java impaired) > has > > | the javap program, which allows you to take a peek into classes, and is > a > > | handy way to get the interface and even private methods and variables. > > | > > | Has anyone written a parser to dump the interface of a D class? > > > > I don't think so. This would be a good spot to have a D grammar available. > > At least one that could parse declarations. > > > > Note javap works on class files, not source files, so I'm not too clear on what you are asking for: to strip out declarations from D source or to > > disassemble some compiled code to get the original D source. > > > > While programmers might be loathe to document code they sure should document APIs - otherwise no-one will want to use it. > > There's no practical way to disassemble object files into declarations. But > D does offer an avenue for automated documentation that C# and Java do not have - Design by Contract. For example, instead of: > > // Input: s is 'a' or 'b' > void foo(char s); > > we have: > > void foo(char s) in { assert(s == 'a' || s == 'b'); } > > This works better because comments are invariably out of date, wrong, incomplete, or missing. There's no ambiguity in the contract, and since it gets executed, it is guaranteed correct. This is true as far as it goes, but it's not that far. You still need documentation. (As I'm sure you know ...) |
February 22, 2004 Re: Downside of the absence of headers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | Mik Mifflin wrote: >Many programmers loathe to document their code. When looking at >undocumented C++ code, it's easy enough to open up a header file to get a >good idea of what a class does and how it works. Though, it's not so easy >in D. Sun Java (which also has no header files, for the Java impaired) has >the javap program, which allows you to take a peek into classes, and is a >handy way to get the interface and even private methods and variables. > >Has anyone written a parser to dump the interface of a D class? > > > What about doxygen? -- -Anderson: http://badmama.com.au/~anderson/ |
Copyright © 1999-2021 by the D Language Foundation