POV-Ray : Newsgroups : povray.general : File load failure : Re: File load failure Server Time
3 Aug 2024 20:18:18 EDT (-0400)
  Re: File load failure  
From: Patrick Elliott
Date: 1 Feb 2004 15:41:06
Message: <MPG.1a87109fc1178b5398998a@news.povray.org>
In article <401c44b8@news.povray.org>, war### [at] tagpovrayorg says...
> Patrick Elliott <sha### [at] hotmailcom> wrote:
> > What you seem to be implying is that both the SDL parser and the #read 
> > command use the same system to retrieve data and that because of this it 
> > ignores the rules used by probably 90% of all programs, which nearly 
> > universally consider newlines as a break in the data.
> 
>   How many programming languages can you mention which consider newline
> as some kind of separator which is different from a space in their input
> language?
>   Does a HTML browser consider a newline in a HTML file as some kind of
> separator different from a space?
> 
>   I wouldn't call it a "universal" fact that a newline character is a
> separator in a data file.
> 

Ok.. The key word here is *DATA*. I was not aware that the #read 
directive was intentionally design to also execute code if found. This is 
imho not a good thing if your intention is, for instance, to read in SDL 
and feed it to part of the script as text, in order to render an overlay 
of the SDL on top of the scene it generates. In other words, take a 
template scene and add something to the end:

#version 3.5;
#include "colors.inc"

global_settings {
  assumed_gamma 1.0
}

// ----------------------------------------

camera {
  location  <0.0, 0.5, -4.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

{snip...}

// Add in here code that uses #open and #read to pull in *this* file and
// generate text overlayed on top of the rest of the image.

Ooops! If #read automatically interprets everything that is SDL as code, 
then this is literally impossible. And even if it somehow worked, you 
can't make it read in one line at a time, so POV-Ray would produce lines 
of text that are 'its' interpretation of how all the bits fit together, 
not the original contents.

Tell me again how this is good? If I want to read in *data* the result 
must arrive in the same condition it was stored. If I want to read SDL, 
then #read's behaviour makes sense. The two are completely different 
situations and therefor #read does not and cannot provide an effective 
and universal solution for both. While dumping the SDL as text over top 
of the scene is a more extreme example, it is exactly the same situation 
as AngleWyrm is talking about. The contents of the file need to be read 
in something approximately identical to how something else output them, 
without accidentally or intentionally trying to interpret it as something 
completely different than the user intends.

As for the idea that is isn't a universal fact that newline is a data 
separator. Maybe not universal, however most databases export individual 
records with comma delimited fields, but use the newline to seperate 
Individual records. A lot of 3D packages also output data with each 
individual object, triangle, etc. on its own line. The data for each 
object is comma delimited, but the objects themselves may use newlines to 
separate them. There are far more cases of this than there are of 
programs that dump everything into a file with commas between both 
individual data elements and each record. I certainly don't know of any 
that I use which behaves the way POV-Ray would expect them to.

The fact is that data may not always have the same number of fields for 
each record. So.. You can't just read 3 values, and repeat. Having a way 
to use a linefeed as a break is more practical. Even when this is not 
true, you would still need to feed any data files that don't conform 
through a program that just tacks on an extra ',', or in the case of my 
above SDL example, actually generate a separate text file, with every 
damn line altered by adding quotes and a comma. Ooops again! That won't 
work for any SDL or other files that already contain quotes of any 
kind...

Fact is: #read cannot and will not provide a universal method for 
retrieving data. It assumes things for the user than the user does not 
intend, want or can in many cases even use. This would no doubt be a real 
winner for a Microsoft product. They excel at making things that think 
for the user, instead of doing what the user actually wants. However it 
shouldn't imho be the only way to read data from a file in POV-Ray.

-- 
void main () {

    call functional_code()
  else
    call crash_windows();
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.