1. fact inquiring questions

Hi

A few questions inquiring facts.

1) when I create a type, with its constraints in the body, when will those constraints be checked?
will they be checked whenever an argument is passed to a function?
let's say I have an alphabet type, where all the sequence items should be between a..z
I then modify one of those items to integer -3.
it can be considered corrupted data now. will the next function check the type again, and assert the error? or is it internally marked as a certain type, so the (invariant) checking is only done at constructor time?

2) let's say i want to use a large library a few mb in size. but only 5 functions are needed from there.
can 'euc' link the library statically to the resulting exe, but without all the unused material?

Thanks alot! Kobi

new topic     » topic index » view message » categorize

2. Re: fact inquiring questions

kobi said...

Hi

A few questions inquiring facts.

1) when I create a type, with its constraints in the body, when will those constraints be checked?
will they be checked whenever an argument is passed to a function?
let's say I have an alphabet type, where all the sequence items should be between a..z
I then modify one of those items to integer -3.
it can be considered corrupted data now. will the next function check the type again, and assert the error? or is it internally marked as a certain type, so the (invariant) checking is only done at constructor time?

The type's function is called when type-checking is not turned off and when any assignment is made to a variable of that type.

type myType (object x) 
 
  if atom(x) then return 0 end if 
  if length(x) != 3 then return 0 end if 
  if x[2] != 1 then return 0 end if 
 
  return 1 
end type 
 
 
myType A 
A = {1,1,1} -- Ok 
 
A[2] = 2 -- Fails 
 
A &= 1  -- Fails 
kobi said...

2) let's say i want to use a large library a few mb in size. but only 5 functions are needed from there.
can 'euc' link the library statically to the resulting exe, but without all the unused material?

I assume you are talking about a library of Euphoria routines. The translator (euc) will not include Euphoria routines from Euphoria libraries that the application does not use. The resulting application is statically linked.

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

3. Re: fact inquiring questions

kobi said...

A few questions inquiring facts.

Euphoria comes with a utility (eudis) that makes it easy to see what euphoria does at a lower level. It parses your code just like either the interpreter or translator (there are some subtle but important differences, especially related to type checking) and outputs the IL code in an assembly-like format. Eudis also outputs the details of the symbol table.

If you have graphviz installed, you can also get a Doxygen like set of html files documenting your application's routines. Here's an example showing the interpreter front end.

Matt

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

4. Re: fact inquiring questions

Thanks a lot for all the information.

Euphoria is looking better and better the more I learn about it. You guys thought it out really well.
Or maybe Rob Craig, I assume he's the main architect all these years.

Derek, I actually meant a c binded library, I should have been more exact.

and Matt, I had this WOW moment, when I saw the eudox tool.
very cool

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

5. Re: fact inquiring questions

kobi said...

Or maybe Rob Craig, I assume he's the main architect all these years.

Rob has not worked on the version 4 edition of Euphoria. He laid the foundation with the language but stopped being active in its development since version 3.2

kobi said...

I actually meant a c binded library

I'm sorry but I'm not sure what you mean exactly by a "c binded library". Are you referring to a library created by a C compiler (and librarian tool)? In which case, what gets included into the final application depends on the abilities of the link editor tool, and has nothing to do with Euphoria.

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

6. Re: fact inquiring questions

DerekParnell said...
kobi said...

I actually meant a c binded library

I'm sorry but I'm not sure what you mean exactly by a "c binded library". Are you referring to a library created by a C compiler (and librarian tool)? In which case, what gets included into the final application depends on the abilities of the link editor tool, and has nothing to do with Euphoria.

Hmm...I suspect that he's asking about a euphoria library translated as a dynamic library.

If that's the case, then we keep anything that would be required for the library to function. Basically, we look at routines as though your code had simply included the library as a normal euphoria code. So any bit of code that could be reached that way will be included.

Any code that couldn't be reached will not be included in the final library. So, for instance, if you included parts of the standard library, but your routines didn't use all of the included file, then some of those routines will not be included in the final library.

When you translate euphoria code, it makes several passes. You may have noticed the translator counting passes when you translate some code. The process it uses is to first parse the code, then make several passes through in "dry run" mode. No actual C code is emitted, but the translators watches what values variables take on, and which routines are actually called.

Eventually, it gets to a point where it's learned all that it can, and it writes out the C code. This is why a simple program may take only a couple of passes before the C code is actually written out. The front end of the interpreter, for instance, takes 11 passes (IIRC).

Matt

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

7. Re: fact inquiring questions

mattlewis said...
DerekParnell said...
kobi said...

I actually meant a c binded library

I'm sorry but I'm not sure what you mean exactly by a "c binded library" ...

Hmm...I suspect that he's asking about a euphoria library translated as a dynamic library.

It was the reference to 'static linking' that confused me. A dynamic library created by Euphoria is not statically linked, and as you say, contains all the functions and other publicly exposed symbols.

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

8. Re: fact inquiring questions

In a major work using Euphoria, and using, I would say about 40-50% of the routines, is there any point in worrying about the final speed of the exe file because unneeded routines have been included? In other words, if memory is not a problem and Euphoria uses very little compared to many languages, and initial compile time to create an exe is not an issue, does it really matter? Also an opposite question: Is there a way of including all the Euphoria routines with a simple command prior to creating exe?

Thanks for the support.

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

9. Re: fact inquiring questions

EUWX said...

... initial compile time create an exe is not an issue, does it really matter?

Are you concerned about the number of passes that the translator does? Another major reason it does this is to look for optimizations it might be able to do, so it can generate better C code.

EUWX said...

Also an opposite question: Is there a way of including all the Euphoria routines with a simple command prior to creating exe?

No ... you're the first that's asked for this. It would make the resulting executable larger for no other purpose than to take up room on disk and RAM. Not something that many people want.

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

10. Re: fact inquiring questions

EUWX said...

Also an opposite question: Is there a way of including all the Euphoria routines with a simple command prior to creating exe?

Not with a command, but you could achieve a similar effect by using routine_id() with a variable. This prevents the translator from being able to figure out which routines can be removed, since any one of them might be passed into the routine_id() call.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu