Page 2 of 2

Re: Refinement of DevCPP.GetCode

PostPosted: Mon May 14, 2018 12:45 pm
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.

Re: Refinement of DevCPP.GetCode

PostPosted: Thu May 17, 2018 4:34 am
by luowy
it can be corrected by add a condition which check the length of the string.

Re: Refinement of DevCPP.GetCode

PostPosted: Fri May 18, 2018 3:17 pm
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

Re: Refinement of DevCPP.GetCode

PostPosted: Tue May 22, 2018 12:20 pm
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

Re: Refinement of DevCPP.GetCode

PostPosted: Tue May 29, 2018 9:00 pm
by Zorko
I agree with Wening Luo.

A string in [code] 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.

Re: Refinement of DevCPP.GetCode

PostPosted: Wed May 30, 2018 6:43 am
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

Re: Refinement of DevCPP.GetCode

PostPosted: Wed May 30, 2018 7:22 am
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.

Re: Refinement of DevCPP.GetCode

PostPosted: Wed May 30, 2018 2:12 pm
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

Re: Refinement of DevCPP.GetCode

PostPosted: Wed May 30, 2018 4:17 pm
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;