1. error in doc

section 4.2.1 it is said that Identifiers must start with a letter
with version 4 underscores are accepted too, should be corrected.

section 4.2.1.1

procedure bar(sequence s="abc", integer n, integer p=1)  
    ? length(s)+n+p  
end procedure  

s paramater should be after n as n is mandaroty

section 4.2.3.3

-- lib.e  
namespace lib.e  

this should be namespace lib

There is a contradiction between 4.4.3 first sentence The ifdef statement is unlike all of the other statements in that it is executed at parse time not runtime.
and section 4.4.3.3
Is ifdef parse time or run time?




Jacques

new topic     » topic index » view message » categorize

2. Re: error in doc

jacques_desch said...

section 4.2.1 it is said that Identifiers must start with a letter
with version 4 underscores are accepted too, should be corrected.

Thanks ... this has now been fixed in the docs.

jacques_desch said...

section 4.2.1.1

procedure bar(sequence s="abc", integer n, integer p=1)  
    ? length(s)+n+p  
end procedure  

s paramater should be after n as n is mandaroty

No it doesn't have to be. There is no requirement in Euphoria for mandatory parameters to come before optional parameters. You can mix them in any way that is appropriate for your routine's usage. The above example is saying that as the second parmeter is mandatory, you must always supply a second parameter. The first and third are optional and can be omitted from the calling code. To omit the first parameter you would code ...

  bar(, 4) 
jacques_desch said...

section 4.2.3.3

-- lib.e  
namespace lib.e  

this should be namespace lib

Thanks, this is now fixed in the docs.

jacques_desch said...

There is a contradiction between 4.4.3 first sentence The ifdef statement is unlike all of the other statements in that it is executed at parse time not runtime.
and section 4.4.3.3
Is ifdef parse time or run time?

I don't see what the contradiction is. Can you show me both sentences to show me what is being contradicted.

The ifdef is executed during the parsing phase. That means that there is NO intermediate language code (IL) generated for the ifdef itself. Remember that the runtime phase only executes IL code.

To recap, the interpreter has two phases - parse-time and run-time. During the parse time, the source code is examined for validity and is converted to IL code. During run time, the IL code is executed, thus bringing your application to life. The ifdef statements are executed by the parser to select optional parts of your source code to convert to IL code.

for X = 1 to 10 do 
ifdef DEBUG then 
    display("DEBUG: Value of X is []", X) 
end ifdef 
    foo(X) 
end for 

The generated IL code for this source depends on if DEBUG has been defined or not. If it is not defined the generated IL code will be for ...

for X = 1 to 10 do 
    foo(X) 
end for 

But if it was defined, the generated IL code would be for ...

for X = 1 to 10 do 
    display("DEBUG: Value of X is []", X) 
    foo(X) 
end for 
new topic     » goto parent     » topic index » view message » categorize

3. Re: error in doc

DerekParnell said...
jacques_desch said...

There is a contradiction between 4.4.3 first sentence The ifdef statement is unlike all of the other statements in that it is executed at parse time not runtime.
and section 4.4.3.3
Is ifdef parse time or run time?

I don't see what the contradiction is. Can you show me both sentences to show me what is being contradicted.

The ifdef is executed during the parsing phase. That means that there is NO intermediate language code (IL) generated for the ifdef itself. Remember that the runtime phase only executes IL code.

Yes, although isn't the warning() statement executed at parse time as well?

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: error in doc

DerekParnell said...
jacques_desch said...

section 4.2.1 it is said that Identifiers must start with a letter
with version 4 underscores are accepted too, should be corrected.

Thanks ... this has now been fixed in the docs.

jacques_desch said...

section 4.2.1.1

procedure bar(sequence s="abc", integer n, integer p=1)  
    ? length(s)+n+p  
end procedure  

s paramater should be after n as n is mandaroty

No it doesn't have to be. There is no requirement in Euphoria for mandatory parameters to come before optional parameters. You can mix them in any way that is appropriate for your routine's usage. The above example is saying that as the second parmeter is mandatory, you must always supply a second parameter. The first and third are optional and can be omitted from the calling code. To omit the first parameter you would code ...

  bar(, 4) 
jacques_desch said...

section 4.2.3.3

-- lib.e  
namespace lib.e  

this should be namespace lib

Thanks, this is now fixed in the docs.

jacques_desch said...

There is a contradiction between 4.4.3 first sentence The ifdef statement is unlike all of the other statements in that it is executed at parse time not runtime.
and section 4.4.3.3
Is ifdef parse time or run time?

I don't see what the contradiction is. Can you show me both sentences to show me what is being contradicted.

The ifdef is executed during the parsing phase. That means that there is NO intermediate language code (IL) generated for the ifdef itself. Remember that the runtime phase only executes IL code.

To recap, the interpreter has two phases - parse-time and run-time. During the parse time, the source code is examined for validity and is converted to IL code. During run time, the IL code is executed, thus bringing your application to life. The ifdef statements are executed by the parser to select optional parts of your source code to convert to IL code.

for X = 1 to 10 do 
ifdef DEBUG then 
    display("DEBUG: Value of X is []", X) 
end ifdef 
    foo(X) 
end for 

The generated IL code for this source depends on if DEBUG has been defined or not. If it is not defined the generated IL code will be for ...

for X = 1 to 10 do 
    foo(X) 
end for 

But if it was defined, the generated IL code would be for ...

for X = 1 to 10 do 
    display("DEBUG: Value of X is []", X) 
    foo(X) 
end for 

All this is clear Derek, what is not clear is the title of section 4.4.3.3 runtime Definitions

As those definitions are to be used at parse-time they don't exist at run-time. Secondly as ifdef is used at parse-time, in the case of translated application there is no ifdef EUC to be executed to check if it is translated or not.

This is what is unclear to me.

Jacques

new topic     » goto parent     » topic index » view message » categorize

5. Re: error in doc

jacques_desch said...

Secondly as ifdef is used at parse-time, in the case of translated application there is no ifdef EUC to be executed to check if it is translated or not.

This is what is unclear to me.

euc has to parse the code initially to make the translation. So, ifdef EUC is done at parse time. Here's an example:

puts(1, "Hello\n") 
ifdef EUC then 
    puts(1, "I am a translated program\n") 
end ifdef 
ifdef EUI then 
    puts(1, "I am an interpreted program\n") 
end ifdef 

C:\myproj> eui myproj.ex 
Hello 
I am an interpreted program 
C:\myproj> euc -keep myprog.ex   rem -keep used to look at the source later 
... translating ... 
... compiling ... 
C:\myproj> myprog.exe 
Hello 
I am a translated program 
C:\myproj> type myprog.c 
... 
EPuts(1, "Hello\n"); 
EPuts(1, "I am a translated program\n"); 
... 

So, the ifdef EUC was executed at parse time which took place during euc myprog.ex. Now, you are right in that the translated program does not execute the "ifdef EUC" check each execution. A translated program is only ever parsed once in it's entire lifetime and that is during translation, not during each execution. That's one of the benefits of a translated program, no parsing stage during execution. Ever.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu