 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I've uploaded the current documentation for my CSDL project at:
http://homepage.mac.com/chrishuff/csdl.html
As for the interpreter, I'll probably just rewrite it, using what I
learned the first time to make the new one better. The core will be
written in platform-independant C++, and the OS X version will have a
Cocoa GUI interface.
Any comments/suggestions?
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Thorsten Froehlich
Subject: Re: CSDL: C-like Simulation Description Language
Date: 12 Jan 2002 12:11:45
Message: <3c406e51@news.povray.org>
|
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> I've uploaded the current documentation for my CSDL project at:
> http://homepage.mac.com/chrishuff/csdl.html
>
> As for the interpreter, I'll probably just rewrite it, using what I
> learned the first time to make the new one better. The core will be
> written in platform-independant C++, and the OS X version will have a
> Cocoa GUI interface.
> Any comments/suggestions?
Looks interesting. The idea of using a simple C/C++ like language with more
abstract data types and then translate to plain C/C++ is really powerful.
Using your idea together with "full" function support in POV-Ray 4.0 * might
i.e. allow to develop POV-Ray source code (like new objects) in POV-Ray
itself and then just run it through a C/C++ converter to generate fast code
after everything has been debugged. This could speed up the development
cycle and the rewrite in general...
Thorsten
* Just mentioning it, I don't want to get into any discussion about 4.0!
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c406e51@news.povray.org>,
"Thorsten Froehlich" <tho### [at] trf de> wrote:
> Looks interesting. The idea of using a simple C/C++ like language with more
> abstract data types and then translate to plain C/C++ is really powerful.
There will be two separate languages, at least at first...SimC will
support all C features (structs, pointers, and other C data types, C
function syntax, etc), while CSDL will have a more simplified syntax
(references instead of pointers, no structs, etc...the expression
handling will be far simpler, at least at first). SimC will be basically
C + odd flavor of OOP + geometric vector type.
I've heard something described as "prototype-based OOP" that sounds
similar to what I'm doing...does anyone have any information about it?
I've started to build a library, and it seems to be a very simple and
powerful way to work...
> Using your idea together with "full" function support in POV-Ray 4.0 * might
> i.e. allow to develop POV-Ray source code (like new objects) in POV-Ray
> itself and then just run it through a C/C++ converter to generate fast code
> after everything has been debugged. This could speed up the development
> cycle and the rewrite in general...
Now that is an interesting idea...I had originally started this project
to try out some ideas I had for the POV 4.0 language, mainly the OOP
ideas. I haven't even started the translator project yet...
BTW, know of any good sites with information on VM/compiler design?
> * Just mentioning it, I don't want to get into any discussion about 4.0!
Ok. ;-)
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Tony[B]
Subject: Re: CSDL: C-like Simulation Description Language
Date: 12 Jan 2002 13:43:37
Message: <3c4083d9@news.povray.org>
|
|
 |
|  |
|  |
|
 |
> ...This could speed up the development
> cycle and the rewrite in general...
I like the sound of this. :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Thorsten Froehlich
Subject: Re: CSDL: C-like Simulation Description Language
Date: 12 Jan 2002 14:09:34
Message: <3c4089ee@news.povray.org>
|
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> BTW, know of any good sites with information on VM/compiler design?
The best intro book I have to compiler design was written in German, see
<http://www.cs.inf.ethz.ch/~wirth/books/Compilerbau1/>.
However, <http://www.cs.inf.ethz.ch/~wirth/books/CompilerConstruction/> is
the English edition of the same book. I checked, and Barnes and Noble asks
it for $52 new, which I have to say is absolutely unreasonable, the German
edition did only cost 40 DM, which is about $20. You can probably get it
used for much less as Amazon says it is out of print.
The nice thing about this book compared to some other books I have is that
rather than showing off the author is very straight to the point. In many
other books I have found complicated and unreadable notation to scare people
and show what complex language theory examples the authors can imagine, yet
all those have zero practical use. In particular I should warn you not to
get "Modern Compiler Implementation in XXX", where XX is C/C++/Pascal/Java.
They simply edited the example sin the book with tons of errors for each
different target language, and the book does not cover a compiler to a
useful language.
This is different in Wirth's book, which uses a subset of the language
Oberon, a successor to Pascal. All examples are extremely easy to read and
understand. Even more important, it is very show, less than 200 pages while
it covers absolutely everything you need to know without getting
side-tracked. Don't get me wrong, you neither need to know or be interested
in Oberon, it only delivers a IMO very effective means to communicate the
general ideas of compiler design.
For his development _of_ Pascal and Modula Wirth received the ACM Turing
Award in 1984, so there is no doubt he is qualified to write about compilers
either.
Once you have read it and gained some experience, I would strongly recommend
to get a copy of Muchnick's "Advanced Compiler Design and Implementation"
book. It covers all important optimization and intermediate representation
techniques developed in the past two decades. Unfortunately it is $90, but
well worth it for the 850 packed pages. Contrary to Wirth's book, it does
not go into implementation details but presents the different techniques in
a mostly independent fashion.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
> I've uploaded the current documentation for my CSDL project at:
> http://homepage.mac.com/chrishuff/csdl.html
>
> As for the interpreter, I'll probably just rewrite it, using what I
> learned the first time to make the new one better. The core will be
> written in platform-independant C++, and the OS X version will have a
> Cocoa GUI interface.
> Any comments/suggestions?
>
Your syntax supports only vectors, but if you are going to support
transformations, then perhaps it would be better to distinguish points,
vectors and normals (as they transform differently)? RenderMan SL
supported in initial versions only points and point transformation
function and this caused quite a lot of problems. Now it has 3 different
data types and separate transformation functions for each one.
If your language will allow 'overridden' functions, then perhaps it
could get away with 1 function (if there is possibility to recognize,
which type was given as actual parameter), but better would be to use 3
different functions, as it improves readability and allows to avoid or
catch errors (IMO).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C4### [at] comtrade ee>,
Vahur Krouverk <vkr### [at] comtrade ee> wrote:
> Your syntax supports only vectors,
Scalars and vectors, actually. Though currently the expression engine
uses the 3D vector code for both.
> but if you are going to support transformations, then perhaps it
> would be better to distinguish points, vectors and normals (as they
> transform differently)?
Only the math is different. The library will eventually include
functions for point and normal manipulation, as well as transformation
objects.
> If your language will allow 'overridden' functions,
I think you mean "overloaded" functions...this is something I've been
thinking of, but it isn't implemented (yet). Of course, parameters
aren't fully implemented yet either...
> then perhaps it could get away with 1 function (if there is
> possibility to recognize, which type was given as actual parameter),
> but better would be to use 3 different functions, as it improves
> readability and allows to avoid or catch errors (IMO).
There will be separate transformation functions for points, vectors, and
normals.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I've gotten a rudimentary expression parser, variables, functions, and
the user output stream working. Objects can be declared, but I haven't
written the code for deriving objects from others or for accessing
members, so they aren't very useful yet.
It's not much, but it is enough for a "Hello World" program:
scalar accum = 5;
function run()
{
string Message = "Hello World!\n";
swrite(userout, Message, "pi = ", pi, newln);
swrite(userout, "Calling aFunc():", newln);
aFunc();
swrite(userout, "aFunc() returned.", newln);
};
function aFunc()
{
scalar Count = 5;
swrite(userout, "Inside aFunc():\n");
while(Count)
{
swrite(userout, "while: ", Count, newln);
swrite(userout, "accum = ", accum, newln);
Count = Count - 1;
accum = accum + 1;
};
};
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
BTW, does anyone have any recommendations for licensing?
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> BTW, does anyone have any recommendations for licensing?
<URL:http://www.perl.com/pub/a/language/misc/Artistic.html> is, as
usual, my suggestion.
Deaken
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C47A740.A76C59F7@sw-tech.com>, Deaken <dwy### [at] sw-tech com>
wrote:
> <URL:http://www.perl.com/pub/a/language/misc/Artistic.html> is, as
> usual, my suggestion.
Looks interesting, I'll take a look at it. I assume I can change
licenses with later releases if I want...the code is mine, right?
Hopefully I'll be uploading an alpha of CSDL later today...I'll probably
just cook up a "do not redistribute or use this code" statement, at
least until it gets out of alpha/beta stage.
The complete lack of response this got is surprising considering the
past discussion POV-Ray licensing has received...maybe putting
"Licensing" in the subject line will help. ;-)
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Christoph Hormann
Subject: Re: Licensing, Was: Re: CSDL Update
Date: 19 Jan 2002 11:48:03
Message: <3C49A342.98185D79@gmx.de>
|
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> Looks interesting, I'll take a look at it. I assume I can change
> licenses with later releases if I want...the code is mine, right?
> Hopefully I'll be uploading an alpha of CSDL later today...I'll probably
> just cook up a "do not redistribute or use this code" statement, at
> least until it gets out of alpha/beta stage.
> The complete lack of response this got is surprising considering the
> past discussion POV-Ray licensing has received...maybe putting
> "Licensing" in the subject line will help. ;-)
>
I suppose the main reason for the lack of interest are the problems
understanding what this can be good for, if you release something
including samples for usage i think the interest will be larger (assuming
it's really something useful of course... ;-))
The Perl Artistic License has the advantage that it forces a distinction
of the original version and custom extensions, apart from that it's much
like GPL i think.
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C49A342.98185D79@gmx.de>,
Christoph Hormann <chr### [at] gmx de> wrote:
> I suppose the main reason for the lack of interest are the problems
> understanding what this can be good for, if you release something
> including samples for usage i think the interest will be larger (assuming
> it's really something useful of course... ;-))
That's somewhat like wondering what C can be good for...
CSDL is a programming language. It is intended to be far easier to learn
than C, and useful for doing any mathematics, simulations, etc. It has a
library that can output POV-Script, manage scene options, and call
POV-Ray, so CSDL can be used to describe scenes. It will also eventually
be able to draw its own graphics with OpenGL, so you could get real-time
visualizations of simulations or previews of scenes.
There are many things that are difficult to do in POV because of the
limitations of its language, or which are just too slow to parse, such
as particle systems, mesh bone animation, other animation methods, etc.
CSDL is intended to make this a lot easier. In addition, it is a kind of
"proof of concept" for some of my ideas for future modifications to the
POV-Script language, to show that the ideas are actually useful.
> The Perl Artistic License has the advantage that it forces a distinction
> of the original version and custom extensions, apart from that it's much
> like GPL i think.
I really know virtually nothing about licensing. Do you know of any web
sites with information for people new to this kind of thing?
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Christoph Hormann
Subject: Re: Licensing, Was: Re: CSDL Update
Date: 19 Jan 2002 13:00:54
Message: <3C49B44C.57404C62@gmx.de>
|
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> That's somewhat like wondering what C can be good for...
> [...]
I know, you already gave quite a lot of description, but that's not the
same as actually seeing a sample simulation.
> In addition, it is a kind of
> "proof of concept" for some of my ideas for future modifications to the
> POV-Script language, to show that the ideas are actually useful.
Having POV-Ray's internal functions available in such a simulation
language (like 'trace' and all the patterns for example) would be very
nice, but i guess this won't happen in the near future.
>
> I really know virtually nothing about licensing. Do you know of any web
> sites with information for people new to this kind of thing?
>
See for example:
http://www.gnu.org/licenses/license-list.html
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C49B44C.57404C62@gmx.de>,
Christoph Hormann <chr### [at] gmx de> wrote:
> Having POV-Ray's internal functions available in such a simulation
> language (like 'trace' and all the patterns for example) would be very
> nice, but i guess this won't happen in the near future.
Well, part of the math library will include functions for intersecting
rays with shapes, but it won't be related to POV-Ray in any way. It is
limited to generating a scene and telling POV to render it.
CSDL itself is completely separate from POV, it just has a "system()"
function that lets other programs be started.
> See for example:
>
> http://www.gnu.org/licenses/license-list.html
It looks like a list of licenses, similar to:
http://www.opensource.org/licenses/index.html
What I'm currently looking for is information on licensing software, not
on the licenses.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Here it is, first alpha release. If anyone wants to do a Windows/Linux
port, just say so.
Supports:
while loops, if-else conditionals
objects
functions with parameters
1D arrays
file output
mathematical expressions. No boolean operators, just +-*/. Parentheses
should work, but are untested. Vectors and scalars work.
To-do for next release:
boolean operators
global variables
general code cleanup, especially the parser
function return values
better documentation/sample files
I just realized I forgot to document the syntax of the CSDL
interpreter...though it is pretty obvious, "csdl INPUT_FILE". Make sure
the executable is alongside the "library" directory or all the files are
in the same directory, or CSDL won't be able to find the library files.
BTW, if you attempt to run the library files, they will print
information about the file.
Source code (20KB):
homepage.mac.com/chrishuff/csdl_source.tgz
Documentation, example files, library files (12KB):
homepage.mac.com/chrishuff/csdl_dist.tgz
Mac OS X compile (208KB):
homepage.mac.com/chrishuff/csdl_macosx.tgz
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> In article <3C47A740.A76C59F7@sw-tech.com>, Deaken <dwy### [at] sw-tech com>
> wrote:
>
> > <URL:http://www.perl.com/pub/a/language/misc/Artistic.html> is, as
> > usual, my suggestion.
>
> Looks interesting, I'll take a look at it. I assume I can change
> licenses with later releases if I want...the code is mine, right?
I don't know. I've seen it done, but I've seen people argue that even the
creator is bound by the license. My guess is that if you do change
licenses, nobody's going to bother to do anything about it. If they have a
problem, they'll use an earlier version that has a license that they like.
It is not something that I've been forced to deal with yet, as most of my
released projects have been very simple and have required neither
maintenance nor feature additions.
Deaken
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> Here it is, first alpha release. If anyone wants to do a Windows/Linux
> port, just say so.
> [...]
>
> Source code (20KB):
> homepage.mac.com/chrishuff/csdl_source.tgz
>
> Documentation, example files, library files (12KB):
> homepage.mac.com/chrishuff/csdl_dist.tgz
>
> Mac OS X compile (208KB):
> homepage.mac.com/chrishuff/csdl_macosx.tgz
>
Those links don't seem to work, i can get 'homepage.mac.com/chrishuff/'
but none of the 3 files is accessible.
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Deaken <dwy### [at] sw-tech com> writes:
> > Looks interesting, I'll take a look at it. I assume I can change
> > licenses with later releases if I want...the code is mine, right?
>
> I don't know. I've seen it done, but I've seen people argue that even the
> creator is bound by the license.
IANAL, but if you are the only contributor to the code base, it's all
under your copyright. So when you do a new release, you're free to
choose another license.
What you can't do is to change the license of an old release, like
this:
1. Release foobar-0.1 under GNU GPL (thus making it free for all).
2. Develop foobar-0.2 and release it with some evil proprietary
license which prohibits people from copying/modifying foobar.
3. Demand that all use of foobar-0.1 comply with the new license.
As long as you're only doing 1 & 2 there's no problem (well, depending
on your point of view there might be some moral problems, and people
are likely to complain...), but you can't legally do 3.
> My guess is that if you do change licenses, nobody's going to bother
> to do anything about it. If they have a problem, they'll use an
> earlier version that has a license that they like.
I think so too. Though I also think that changing license to something
more prohibitive is going to make some people angry.
My suggestion for licensing is: don't make up a new one yourself,
since a) you would probably need lawyer help to ensure it is good
enough, b) the world already has enough licenses. :-)
Else, I would suggest GNU GPL because choosing that makes it possible to
share code with the rest of the GNU world and avoid license wars with
various parties (that's the pragmatic reason, anyway). And then you
don't have to worry that someone will steal your code and abuse it in
some future commercial product.
--
Ole Laursen
http://sunsite.dk/olau/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C4AA1F5.298177D8@gmx.de>,
Christoph Hormann <chr### [at] gmx de> wrote:
> Those links don't seem to work, i can get 'homepage.mac.com/chrishuff/'
> but none of the 3 files is accessible.
Oops...these should work:
Source code (20KB):
homepage.mac.com/chrishuff/csdl/csdl_source.tgz
Documentation, example files, library files (12KB):
homepage.mac.com/chrishuff/csdl/csdl_dist.tgz
Mac OS X compile (208KB):
homepage.mac.com/chrishuff/csdl/csdl_macosx.tgz
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff scribis news:chrishuff-
AD4### [at] netplex aussie org:
>
> Here it is, first alpha release. If anyone wants to do a Windows/Linux
> port, just say so
I would be intrested in working on a BeOS port (only OS I have a good IDE
for).
But the files are "not avaliable" at the links you gave.
--
Gis poste, Arto.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <87w### [at] bach composers>,
Ole Laursen <ola### [at] hardworking dk> wrote:
> 3. Demand that all use of foobar-0.1 comply with the new license.
>
> As long as you're only doing 1 & 2 there's no problem (well, depending
> on your point of view there might be some moral problems, and people
> are likely to complain...), but you can't legally do 3.
If I understand things properly, #3 is legal if the old license
specifically stated that the license could be changed, so anyone using
the software has warning.
> Else, I would suggest GNU GPL because choosing that makes it possible to
> share code with the rest of the GNU world and avoid license wars with
> various parties (that's the pragmatic reason, anyway). And then you
> don't have to worry that someone will steal your code and abuse it in
> some future commercial product.
But I worry about people *not* using it because it is GPL...some people
apparently don't like GPL, which is why I'm looking on information about
licensing.
The artistic license seems interesting...it looks like it would let
people use it in a program and only have to release the CSDL part of the
source code. The only other thing is that I want to be sure people know
they're using CSDL, what it is, and where it came from. I basically
don't want someone to take the code, maybe make it slightly incompatible
and release it as something else or use it as the main feature of their
program and make it look like their work.
If someone is willing to invest the time/money to make a product that
uses CSDL, I would have nothing against them charging for their product
or withholding the source code for their work, as long as they make any
changes/enhancements to CSDL available. People will only buy it if it is
better than the free stuff, and if the developer makes something better,
I'll thank them.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Arthur Flint scribis
news:Xns### [at] 204 213 191 226:
> Christopher James Huff scribis news:chrishuff-
> AD4### [at] netplex aussie org:
> I would be intrested in working on a BeOS port (only OS I have a good
> IDE for).
Found the correct links, thanks.
And congrats! The source compiled first time, no errors.
(a few warnings, but no errors)
So, when you have another release to let us try, let me know.
--
Gis poste, Arto.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
It compiles fine in Cygwin - now to figure out how to use it :-)
--
duncan gold [TurboPower]
TurboPower: http://www.turbopower.com
Personal: http://www.autowitch.org
"Christopher James Huff" <chr### [at] mac com> wrote in message
news:chr### [at] netplex aussie org...
> Here it is, first alpha release. If anyone wants to do a Windows/Linux
> port, just say so.
>
> Supports:
> while loops, if-else conditionals
> objects
> functions with parameters
> 1D arrays
> file output
> mathematical expressions. No boolean operators, just +-*/. Parentheses
> should work, but are untested. Vectors and scalars work.
>
> To-do for next release:
> boolean operators
> global variables
> general code cleanup, especially the parser
> function return values
> better documentation/sample files
>
>
> I just realized I forgot to document the syntax of the CSDL
> interpreter...though it is pretty obvious, "csdl INPUT_FILE". Make sure
> the executable is alongside the "library" directory or all the files are
> in the same directory, or CSDL won't be able to find the library files.
> BTW, if you attempt to run the library files, they will print
> information about the file.
>
> Source code (20KB):
> homepage.mac.com/chrishuff/csdl_source.tgz
>
> Documentation, example files, library files (12KB):
> homepage.mac.com/chrishuff/csdl_dist.tgz
>
> Mac OS X compile (208KB):
> homepage.mac.com/chrishuff/csdl_macosx.tgz
>
> --
> --
> Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4cb4df$1@news.povray.org>,
"autowitch" <aut### [at] autoSPAMwitch org> wrote:
> It compiles fine in Cygwin - now to figure out how to use it :-)
Well, at least nobody's having trouble compiling it...
Alpha 1 only takes one parameter, the CSDL file to run. Make sure the
CSDL executable is in the same directory as the demo files and library
folder. And if you need any help on the language itself, ask...the
documentation is pretty bad, but the language should be fairly easy for
anyone who can handle POV-Script or C.
BTW, I just got OpenGL display (using GLUT) working...and I almost have
function return values working.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff scribis news:chrishuff-
9F0### [at] netplex aussie org:
> In article <3c4cb4df$1@news.povray.org>,
> "autowitch" <aut### [at] autoSPAMwitch org> wrote:
>
>> It compiles fine in Cygwin - now to figure out how to use it :-)
>
> Make sure the CSDL executable is in the same directory as the
> Demo files and library folder.
Can it be stored in a directory in the system path and run that way?
Or does it store all output files in the same dir that the binary is
stored in? Do you plan to use an *.ini file that lets it know where
to find needed files?
>
> BTW, I just got OpenGL display (using GLUT) working...and I almost have
> function return values working.
>
Please let us know when you have another release.
--
Gis poste, Arto.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <Xns### [at] 204 213 191 226>,
Arthur Flint <mra### [at] chesapeake net> wrote:
> Can it be stored in a directory in the system path and run that way?
> Or does it store all output files in the same dir that the binary is
> stored in? Do you plan to use an *.ini file that lets it know where
> to find needed files?
I've already added a command-line option to specify an alternate place
to look, that library path was just a quick fix to give me some way of
keeping my files organized. An *.ini file method is certainly a
possibility, as I add more options.
> Please let us know when you have another release.
I plan to do Alpha 2 this Saturday, it will be a lot more useable and
useful, with things like a graph object and rewritten documentation.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> Here it is, first alpha release. If anyone wants to do a Windows/Linux
> port, just say so.
>
Ok, i have finally found some time to have a look, as autowitch mentioned
it compiles with cygwin, even with -mno-cygwin/MinGW (in case you want to
use a non open source license) For future versions a makefile would of
course be useful.
The samples all worked, starting Povray of course not, but that's just a
small change in the 'povray.csdl' file. The indention of the Povray
output could be improved, but you probably already noticed that.
The syntax is pretty self explanatory although learning everything will
probably take some time. But it seems that writing malicious programs is
quite easy so you should consider some security mechanism like Povray's
IO-restrictions.
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C4EDD1C.848E9D11@gmx.de>,
Christoph Hormann <chr### [at] gmx de> wrote:
> Ok, i have finally found some time to have a look, as autowitch mentioned
> it compiles with cygwin, even with -mno-cygwin/MinGW (in case you want to
> use a non open source license) For future versions a makefile would of
> course be useful.
Especially since it now uses GLUT...I'll get to work on one, but I have
very little experience in such things, beyond modifying them to compile.
> The samples all worked, starting Povray of course not, but that's just a
> small change in the 'povray.csdl' file.
Hmm? What changes were necessary? Is POV-Ray not named "povray" on your
system?
I'll eventually have the engine name be a variable, it was mainly
hard-coded because there are no string manipulation functions yet. The
same goes for the source file name.
> The indention of the Povray output could be improved, but you
> probably already noticed that.
In the current POV library, I've removed all indentation...it won't be
too hard to implement though, I just haven't done it because I haven't
decided on the best way to store the data.
> The syntax is pretty self explanatory although learning everything will
> probably take some time. But it seems that writing malicious programs is
> quite easy so you should consider some security mechanism like Povray's
> IO-restrictions.
More dangerous is the system() function...I'll eventually add security
features to limit file I/O and turn that function off, though they will
probably be platform-specific extensions to the core code. I'm focusing
on getting the thing fully operational first...
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff wrote:
>
> Hmm? What changes were necessary? Is POV-Ray not named "povray" on your
> system?
> I'll eventually have the engine name be a variable, it was mainly
> hard-coded because there are no string manipulation functions yet. The
> same goes for the source file name.
It's 'pvengine.exe' but it's usually not in search path and the windows
version is not very suited for automatic starting anyway so most people
will either not use the render function or have a command line version.
>
> More dangerous is the system() function...I'll eventually add security
> features to limit file I/O and turn that function off, though they will
> probably be platform-specific extensions to the core code. I'm focusing
> on getting the thing fully operational first...
I mostly meant 'system()', i think it would be good if you could have a
confirmation before executing a program.
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3C4EED6E.32F4EB5E@gmx.de>,
Christoph Hormann <chr### [at] gmx de> wrote:
> I mostly meant 'system()', i think it would be good if you could have a
> confirmation before executing a program.
That would be a possibility...it would have three settings: always
execute, ask, and never execute. The code would be conditionally
compiled, so it could be specialized for specific platforms.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> Here it is, first alpha release.
I didn't run or compile it, I just looked at the code. I have to say it is
nicely formatted and good to read. Of course some comments would help
others to understand, but nevertheless, your code is still fairly clear and
in parts seems like "Java style" to me (I don't know why, and it is meant
positive).
However, there is one thing you should really start adding soon:
try-catch blocks. As it stands your program will just terminate if it runs
out of memory...
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4f050d@news.povray.org>,
"Thorsten Froehlich" <tho### [at] trf de> wrote:
> I didn't run or compile it, I just looked at the code. I have to say it is
> nicely formatted and good to read. Of course some comments would help
> others to understand, but nevertheless, your code is still fairly clear and
> in parts seems like "Java style" to me (I don't know why, and it is meant
> positive).
Good to hear...I was afraid it would be an unreadable mess to anyone
else. ;-)
Java style? Hmm...I have "learned" the Java language, but never bothered
to learn the API, and I haven't done anything in it. Maybe it comes from
my working with Objective C...I've heard both were inspired partly by
Smalltalk. Or do you mean all the inline functions in the headers? That
was just lazyness.
BTW, now that I've done some stuff in Objective C and am back working in
C++, I'm beginning to see why people complain about the way C++ does OOP.
I'm constantly wrestling with it, trying to get it to do things that
should be very simple with OOP, but have to be worked around because C++
isn't dynamic enough. Still better than raw C, though...
Probably too soon to ask, but what do you think of the CSDL language
itself? Do you know of any other languages that use this concept of OOP?
> However, there is one thing you should really start adding soon:
> try-catch blocks. As it stands your program will just terminate if it runs
> out of memory...
Error handling is definitely something I need to work on...I've never
used exceptions before, and I've been putting it off. Right now I'm
mainly working on plugging memory leaks...there's a lot of them, mainly
due to a lot of the code being stubbed out or simply not implemented.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff <chr### [at] mac com> wrote:
: BTW, now that I've done some stuff in Objective C and am back working in
: C++, I'm beginning to see why people complain about the way C++ does OOP.
: I'm constantly wrestling with it, trying to get it to do things that
: should be very simple with OOP, but have to be worked around because C++
: isn't dynamic enough.
Could you give some examples?
(Funnily enough, I seldom have any problems with C++, but the rare cases
where I have to code something with Java, I have to "constantly wrestle" with
it because it has so many braindead limitations which force you to make
non-modular code.)
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4f248e@news.povray.org>, Warp <war### [at] tag povray org>
wrote:
> (Funnily enough, I seldom have any problems with C++, but the rare cases
> where I have to code something with Java, I have to "constantly wrestle" with
> it because it has so many braindead limitations which force you to make
> non-modular code.)
Having to duplicate essentially the same code for every subclass (for a
Copy() function) just so I can make a copy of an object from a
base-class pointer. Having to return void pointers and cast them to the
correct types. Mostly having what I can do with an object being
determined by the type of pointer to it I have, instead of what the
object can do. Templates.
I haven't done anything in Java though, I don't really know what
limitations it has. It might be worse.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff <chr### [at] mac com> wrote:
: Having to duplicate essentially the same code for every subclass (for a
: Copy() function) just so I can make a copy of an object from a
: base-class pointer.
I'm not completely sure what you are talking about, but that sounds a bit
like very dubious coding.
Do you mean that your Copy() method allocates dynamically a new instance
of its own type, copies itself to it and then returns a pointer to this new
instance?
That really badly breaks modular OO design.
: Having to return void pointers and cast them to the
: correct types.
I never have to do this. It also breaks badly modular OO design.
: Mostly having what I can do with an object being
: determined by the type of pointer to it I have, instead of what the
: object can do.
I don't understand this one.
Are you sure you fully understand object-oriented design?
You are also talking too much about pointers. Sounds like you are using
pointers for almost everything.
This is C++, not Java. Here you can use true references and local instances,
true member instances. You don't need to use dynamic allocation for everything,
as in Java (in fact, it's usually a good idea to not to use it unless it's
justified).
: Templates.
What about them?
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> Having to duplicate essentially the same code for every subclass (for a
> Copy() function) just so I can make a copy of an object from a
> base-class pointer.
Well, while I admit the lack of this being available via the language can be
annoying in some cases, it is also important to not have a copy always
create something one didn't ask for.
And you don't need to duplicate any code at all. Simply make your copy
function virtual. That way by default the copy function of the subclass
will be called. In that function simply write "return new SubClass(*this);"
and all your problems are gone.
> Having to return void pointers and cast them to the
> correct types. Mostly having what I can do with an object being
> determined by the type of pointer to it I have, instead of what the
> object can do.
Hmm, this really should not happen. You can always avoid this problem with
a common base class. Even if there are some problems in your class design
this at least allows you to not have to store void pointers, which is an
indication of some problem in the class design. Try to get access to a copy
of "Design Patterns - Elements of Reusable Object-Oriented Software", it
illustrates some good designs.
> Templates.
Well, keep in mind that the most powerful feature of templates, the "export"
keyword is not supported in any compiler yet. Once it will be available
templates have a potential far greater than what i.e. Java offers for
reusable containers. Basically the export keyword has the power to
completely delegate the choice of code reuse to the compiler. Current
compilers will duplicate a lot of similar code, and some will then hope for
the linker to cleanup the mess. Of course, this way a lot of potential
using the available information for optimization is lost :-(
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> Probably too soon to ask, but what do you think of the CSDL language
> itself?
I am sorry, I only looked at the source code to find out more about your
basic programming skills. There isn't enough time in the foreseeable future
to do anything else.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich <tho### [at] trf de> wrote:
: return new SubClass(*this);
Uh. That hurts my eyes.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4f310d@news.povray.org>, Warp <war### [at] tag povray org>
wrote:
> I'm not completely sure what you are talking about, but that sounds a bit
> like very dubious coding.
> Do you mean that your Copy() method allocates dynamically a new instance
> of its own type, copies itself to it and then returns a pointer to this new
> instance?
> That really badly breaks modular OO design.
And how else am I supposed to get a copy?
That isn't exactly what it does, it relies on the constructor to copy
the information, but a virtual Copy() method is the only way to make
sure the correct constructor is called when I don't know the exact type.
> : Having to return void pointers and cast them to the
> : correct types.
> I never have to do this. It also breaks badly modular OO design.
Which is why I don't like it. I'll probably move to casting the data
wrapper type to the right subclass, and having the subclasses return the
data intact...that isn't really any prettier of a solution, but will let
me get rid of the void pointers, which make me nervous.
> : Mostly having what I can do with an object being
> : determined by the type of pointer to it I have, instead of what the
> : object can do.
> I don't understand this one.
> Are you sure you fully understand object-oriented design?
In C++, if you have a derived object that implements a certain method
not in its base class, but only have a base-class pointer to it, you
can't call that method unless you cast to that type. It's a pain that
produces ugly code, that's all. In Objective C, the methods you can call
are determined by what the object itself responds to, at runtime, not by
the type of pointer you have.
> You are also talking too much about pointers. Sounds like you are using
> pointers for almost everything.
Pretty much.
> This is C++, not Java. Here you can use true references and local
> instances, true member instances. You don't need to use dynamic
> allocation for everything, as in Java (in fact, it's usually a good
> idea to not to use it unless it's justified).
I've been avoiding using references, I don't like them for the simple
reason that a call passing a variable by reference looks exactly the
same as one passing a variable by value, and I have a pointer most of
the time anyway. Pointer syntax isn't that hard to figure out.
And I have to use dynamic allocation because the objects are going to
stick around for an indefinite amount of time, they can't be deleted
when the function goes out of scope. Local instances aren't that useful
in this program, though I use them when I can.
> : Templates.
>
> What about them?
They make my head hurt. ;-)
They're fine unless there's a problem. If there's a problem, it's often
very difficult to figure out what it is from the error messages. And the
syntax looks like something just tacked onto the C language, but my
complaint is mainly about the error messages they give. Fortunately,
they haven't been causing me any trouble in CSDL...
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi Warp, you recently wrote in povray.general:
> Thorsten Froehlich <tho### [at] trf de> wrote:
> : return new SubClass(*this);
>
> Uh. That hurts my eyes.
Why? That's the standard way of cloning an object (standard in the
sense of widely used). Simply invoke the copy constructor on the
current instance. How else would you write a Clone() or Copy()
function?
- Lutz
email : lut### [at] stmuc com
Web : http://www.stmuc.com/moray
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Wed, 23 Jan 2002 17:54:07 -0500, Christopher James Huff wrote:
> In C++, if you have a derived object that implements a certain method
> not in its base class, but only have a base-class pointer to it, you
> can't call that method unless you cast to that type. It's a pain that
> produces ugly code, that's all. In Objective C, the methods you can call
Only if you let it.
Clearly Warp hasn't asked the right question. The right question is, why
do you have a base-class pointer if you want a derived-class pointer?
The reason for all this is pretty simple. If all you have is a base-class
pointer, how do you know that it's a pointer to an instance of the right
derived class? Without more information, you don't. The cast is how you
tell the compiler that it's all right, you've thought of that, and you
really do want to do what you're doing.
--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4f3723@news.povray.org>,
"Thorsten Froehlich" <tho### [at] trf de> wrote:
> And you don't need to duplicate any code at all. Simply make your copy
> function virtual. That way by default the copy function of the subclass
> will be called. In that function simply write "return new SubClass(*this);"
> and all your problems are gone.
That's what I do, that was the duplicate code I was talking about...I
just get tired typing that stupid one-liner in every time, when a
subclass only needs to change one method.
> > Having to return void pointers and cast them to the
> > correct types. Mostly having what I can do with an object being
> > determined by the type of pointer to it I have, instead of what the
> > object can do.
> Hmm, this really should not happen.
Yeah, I can get around it, but the code's not really any better. I'm
going to redesign that portion of the code to use templates and get rid
of the void pointers for the next alpha...
> Well, keep in mind that the most powerful feature of templates, the "export"
> keyword is not supported in any compiler yet. Once it will be available
> templates have a potential far greater than what i.e. Java offers for
> reusable containers. Basically the export keyword has the power to
> completely delegate the choice of code reuse to the compiler. Current
> compilers will duplicate a lot of similar code, and some will then hope for
> the linker to cleanup the mess. Of course, this way a lot of potential
> using the available information for optimization is lost :-(
I'm not sure quite what you mean...though if no compilers support it
yet, I guess it doesn't really matter.
--
--
Christopher James Huff <chr### [at] mac com>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> In C++, if you have a derived object that implements a certain method
> not in its base class, but only have a base-class pointer to it, you
> can't call that method unless you cast to that type. It's a pain that
> produces ugly code, that's all. In Objective C, the methods you can call
> are determined by what the object itself responds to, at runtime, not by
> the type of pointer you have.
Not really. dynamic_cast<> does exactly the same, with the only difference
that you have the choice of the object you actually want to respond. It
protects you from getting a pointer to a base and then calling some method
by accident also you never wanted to call that method of that object. In
C++ you are protected from this because you have to explicitly say _what_
you want rather than having the system take a guess and possibly giving you
something you never asked for.
Most important, dynamic_cast<> is fully type-safe, which seems to be what
you are missing. Further, it is significantly more efficient because you
only do the dynamic casting once (by casting the first time you need to
access that particular object and storing the it in a local pointer of the
correct type), while in Objective C, for repeated calls to various functions
the compiler would have to employ (nearly) impossible analysis of the code
to turn it into just one call. Thus it has to run the dynamic casting code
every time, which is extremely inefficient.
Apart from this, without dynamic_cast<>, multiple inheritance would be far
more difficult to use.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> They make my head hurt. ;-)
> They're fine unless there's a problem. If there's a problem, it's often
> very difficult to figure out what it is from the error messages. And the
> syntax looks like something just tacked onto the C language, but my
> complaint is mainly about the error messages they give. Fortunately,
> they haven't been causing me any trouble in CSDL...
Like these two (yes, *two*)? The errors were so simple, I don't even
remember what they were, and I am not going to track them down from this
message again!
Error : function call 'insert(std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>)' does not match
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>>>>::insert(const
std::pair<const std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>> &)'
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>,
std::allocator<char>>>>>>>::insert(std::__tree<std::pair<const
std::basic_string<char, std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>>,
std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>>>>::value_compare,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>>>>::iterator, const
std::pair<const std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>> &)'
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::list<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>>>, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>,
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>>>>>::insert<...>(T1_0, T1_0)'
povdocgen.cpp line 195 attributelists.insert(attribute, entries);
Error : function call 'insert(std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor *)' does not match
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor *>>>::insert(const
std::pair<const std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *> &)'
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor
*>>>::insert(std::__tree<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor *>,
std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor
*>>>::value_compare, std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor *>>>::iterator,
const std::pair<const std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *> &)'
'std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char>>, Processor *, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char>>>,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char>>, Processor
*>>>::insert<...>(T1_0, T1_0)'
povdocgen.cpp line 858 processors.insert(processor, this);
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff <chr### [at] mac com> wrote:
: And how else am I supposed to get a copy?
Needing to do this with just mere base class pointers is clear sign that
you haven't designed your object hierarchy well.
For example in our project I have implemented a bitvector which has some
functionalities needed in our libraries that std::vector<bool> doesn't have,
and which implements the copy-on-write technique for efficiency (these
bitvectors are copied a lot and modified very seldom). (If you don't know
what the copy-on-write technique means, just ask.)
It either allocates the bit array dynamically or uses a user-given memory
location (kind-of placement new functionality).
Of course this is a very different situation than yours, but now I'm getting
to my point: Things are allocated dynamically, copied, freed and so on, but
all inside the bitvector class. The bitvector handles everything.
From outside I only need to use instances of this bitvector. I can assign
this bitvector, give it as a value parameter, return it by value, everything
that can be done by value (ie, no pointers) and it still is efficient, no
matter how large the bitvector is. It itself takes care of everything related
to pointer and dynamic allocation *inside* itself, privately. I don't see what
it does from outside, and I don't even want to see it.
That's the whole point of modularity.
One of the main principles of modularity is that if a module reserves a
resource (eg. memory), the same module (moreover, with just a few exceptions,
the same instance of the module which made the allocation) takes care of
freeing this resource and that no leaks happen.
A module which allocates a resource and then returns a handle to this
resource to the outside, to the upper level and *hopes* that it gets freed
somewhere else, is almost always a sign of a really, really bad module design.
Designing a good, working and secure object hierarchy is not something to
be done lightly, not even in medium to small sized programs. If you make
a good design, you'll gain a lot later.
:> : Having to return void pointers and cast them to the
:> : correct types.
:> I never have to do this. It also breaks badly modular OO design.
: Which is why I don't like it.
One of the reasons why so many people love Java and hate C++ is that
Java simply doesn't support "bad" features from C, while C++ does (for
compatibility). Usually people who learn C++ come from C, where they learnt
really bad habits, which they can't get rid of in C++ for long, long time
(unless they have very good teachers). The good thing in Java is that it just
doesn't have these bad ways of doing things, so you just can't use them.
Personally I dislike Java because in my opinion it has gone just way too
far with its limitation of "bad" features (which really aren't). Java has
many good things, and many of the limitations are things that I don't really
miss (eg. "kludgy" pointer casts), but on the other hand it misses things
that are really useful in C++ and helps a lot in implementing modularity
(even though some of these things *might* be possible to use in a wrong way,
I don't, so removing them is a true limitation to me).
: In C++, if you have a derived object that implements a certain method
: not in its base class, but only have a base-class pointer to it, you
: can't call that method unless you cast to that type.
I don't want to sound rude, but you should really study object orientedness
principles in more detail.
In an object-oriented hierarchy a module/function which takes a base class
reference/pointer is only interested in the base class interface. It does
not know, and moreover it doesn't even want to know, if there's really a
derived class behind that reference or pointer. It just sees a base class
and period (the derived class *is a* base class by all practical means); it's
not interested in anything else.
If this kind of module/function needs to know more, it's usually a sign
of bad OO design.
: I've been avoiding using references
Bad idea. You should really use references instead of pointers whenever
possible (and *const* references whenever possible).
It's much easier to shoot yourself in the foot with pointers than with
references.
It's not a syntax thing (syntax is usually the least of your worries). It's
a higher level thing.
: And I have to use dynamic allocation because the objects are going to
: stick around for an indefinite amount of time, they can't be deleted
: when the function goes out of scope.
That's where you should make a module (ie a class) to handle this and not
just leave the pointers float around and hope that they will sometime be
freed by something. That sounds a lot like what you want to do is a
container class (ie. a class that contains objects and takes care of creating
and destroying them).
:> : Templates.
:>
:> What about them?
: They make my head hurt. ;-)
Templates are incredibly versatile. In fact, it has been proven that
templates (with C++ types) alone are a turing-strong language. You can
make loops, lists, trees, conditionals, etc. which are evaluated at
compilation time (ie. you can, for example, make a list of constant int
values, add values at the end of the list, remove values from the list,
join lists, traverse a list etc, all at compilation time).
(This is actually a whole field of research, called "generative
programming".)
Templates have saved me a lot of work in many places.
: They're fine unless there's a problem. If there's a problem, it's often
: very difficult to figure out what it is from the error messages.
Templates have their problems, and error messages are one of them (the
other is that no compiler yet has implemented export templates, which means
that your object files will be HUGE if you use lots of big templates).
However, you get used to them with experience. (Also with experience you
just usually avoid the error messages completely :P )
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Lutz Kretzschmar <lut### [at] stmuc com> wrote:
: Why? That's the standard way of cloning an object (standard in the
: sense of widely used). Simply invoke the copy constructor on the
: current instance. How else would you write a Clone() or Copy()
: function?
It may be a standard way in Java. In C++ it's a standard way of getting
sure that you will get a high chance of a memory leak (specially if there's
more than one person using the library which does that). (And no, the way
Java handles object allocation and freeing is not always good.)
As I already said in another article, one of the basic principles of
modularity is that if a module (class, whatever) allocates a resource, the
same module takes care that the resource gets freed (and gets freed only
once).
Making a module which allocates a resource, returns a handle to this
resource outside and hopes that someone else will hopefully free it somewhere,
is a *really* bad module design (and OO design).
The whole class hierarchy should be designed so that this kind of copying
is not needed (ie. not in this way). This usually can be done much better
and much more nicely (and specially much more safely).
Making efforts for a good design now can save you a lot of trouble later.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich <tho### [at] trf de> wrote:
: Apart from this, without dynamic_cast<>, multiple inheritance would be far
: more difficult to use.
I have used multiple inheritance. I haven't needed dynamic_cast<> (nor
any other cast for that matter).
dynamic_cast<> is one of those casts which you just shouldn't use (ok,
not that; what I mean is that you should almost never use downcasting;
downcasting is generally bad).
The other casts you should never use are const_cast<> (used just as a hack
for dealing with old bad-designed libraries) and reinterpret_cast<> (which
is mainly used for low-level hacking).
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <chr### [at] netplex aussie org> ,
Christopher James Huff <chr### [at] mac com> wrote:
> I'm not sure quite what you mean...though if no compilers support it
> yet, I guess it doesn't really matter.
Imagine
list<MyClassA> lista;
list<MyClassB> listb;
where MyClassA and MyClassB have no common base.
Compilers right now just copy the code for all functions. Later the linker
will only strip unused functions, but that is all.
However, if the compiler collects the requirements (the misc operator member
functions, i.e. constructors, destructors, comparison operators) in advance,
it could exploit this advance knowledge. For example then the function to
insert an element would be the same, it would only have to know what class
the user wishes to insert and then call the constructor of that class
dynamically.
To understand why this isn't possible without "export" is that the compiler
only looks at one translation unit (a source file) at a time. The "export"
keyword basically tells the compiler that there is shared code. Of course,
onyl could simply parse all translation units and treat them as one, but
doing so would require so much memory for a mid-sized project, we cannot
dream about for decades to come! *
Thorsten
* Just imagine that with optimizations, CW needs over 100 MB of memory for
some source files in POV-Ray. Now consider there are 100 of those files,
and you fill 5-10 GB quickly! Of course, POV-Ray can be considered a
"small" project compared to most commercial applications these days...
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3c4f3a4c@news.povray.org> , Warp <war### [at] tag povray org> wrote:
> Thorsten Froehlich <tho### [at] trf de> wrote:
> : return new SubClass(*this);
>
> Uh. That hurts my eyes.
So I assume you don't read "The C++ Programming Language" from Stroustrup?
Well, at least you will have to stop reading it now that I direct your
attention to p. 424 (in the 3rd edition paperback of the book) aka section
15.6.2 "Virtual Constructors". After all, you should really not hurt your
eyes intentionally! ;-)
Thorsten
PS: I am sorry, but it looks like you lost this argument...
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |