Refinement of DevCPP.GetCode

Zorko
Posts: 26
Joined: Tue Sep 17, 2013 10:13 pm
Location: Ukraine
Contact:

Re: Refinement of DevCPP.GetCode

Post by Zorko »

I tested this code, and it works fine on all my tests that I used.
With the exception of one moment! Empty strings are still allowed. Do you see any practical meaning in this?

Code: Select all

PROCEDURE {code} Proc1"", "", "", 9,  "", "" ; (* <= now it compiles! *)
I'm sure that empty strings should not be allowed in a body of a code procedure either.
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Refinement of DevCPP.GetCode

Post by luowy »

it can be corrected by add a condition which check the length of the string.
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Refinement of DevCPP.GetCode

Post by Josef Templ »

# empty string:
Why should we add any code for testing such an exotic case?
And why should it be considered wrong at the first place?

- Josef
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Refinement of DevCPP.GetCode

Post by luowy »

Josef Templ wrote:# empty string:
Why should we add any code for testing such an exotic case?
And why should it be considered wrong at the first place?

- Josef
the empty string produce nothing,
not like accept nonsense code in the source, no need follow the syntax of empty "WITH" clause .

luowy
Zorko
Posts: 26
Joined: Tue Sep 17, 2013 10:13 pm
Location: Ukraine
Contact:

Re: Refinement of DevCPP.GetCode

Post by Zorko »

I agree with Wening Luo.

A string in

Code: Select all

 procedures in general has very specific application, and a big programmer's accuracy is necessary here. Therefore it is good when a translator will warn of a meaningless design.
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Refinement of DevCPP.GetCode

Post by Josef Templ »

My understanding is that strings in GetCode are mainly supported because once there was a version of BlackBox that
translated to C code and code procedures were strings of C code.
For the i386 native code compiler you would not use strings for code procedures.

- Josef
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Refinement of DevCPP.GetCode

Post by luowy »

Josef Templ wrote:My understanding is that strings in GetCode are mainly supported because once there was a version of BlackBox that
translated to C code and code procedures were strings of C code.
For the i386 native code compiler you would not use strings for code procedures.

- Josef
we need only forbidden empty string, it's meaningless in the code.
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Refinement of DevCPP.GetCode

Post by Josef Templ »

> we need only forbidden empty string, it's meaningless in the code.

It has a well-defined meaning and it does not cause any problems and it is not used at all.
Therefore I strongly believe that it is not worth extra code for checking it and it is not worth extra docu for defining it to be illegal.
You can even construct (theoretical) cases where it may be convenient,
for example if you generate a C code procedure line by line from some source text.
Then you don't have to check for this special case.

- Josef
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Refinement of DevCPP.GetCode

Post by luowy »

luowy wrote:It has a well-defined meaning and it does not cause any problems and it is not used at all.
Therefore I strongly believe that it is not worth extra code for checking it and it is not worth extra docu for defining it to be illega
I think these empty strings useless and make source code dirty,hard to read;

Code: Select all

PROCEDURE {code} Proc1"", "", "", 9,  "", "" ; 
it should be

Code: Select all

PROCEDURE {code} Proc1  9; 
the check is very cheap:

Code: Select all

....  
ELSIF (cx.typ.form = String8)&(cx.conval.intval2 >1)THEN 
....
You can even construct (theoretical) cases where it may be convenient,
for example if you generate a C code procedure line by line from some source text.
Then you don't have to check for this special case.
I know you are maintaining the Ofront at same time, I have no experience about it, you choice may be good for it;
let's stop this discussion;
Post Reply