1. Can types be global

This works (in the same file).

type caps(integer x)
  return x >= 'A' and x<= 'Z'
end type

This doesn't in an incude file.

global type caps(integer x)
  return x >= 'A' and x<= 'Z'
end type

Why whats wrong?

Don Cole

new topic     » topic index » view message » categorize

2. Re: Can types be global

don cole wrote:

> This works (in the same file).
> 
> type caps(integer x)
>   return x >= 'A' and x<= 'Z'
> end type
> 
> This doesn't in an incude file.
> 
> global type caps(integer x)
>   return x >= 'A' and x<= 'Z'
> end type
> 
> Why whats wrong?
> 
> Don Cole

Of course can types be global.
A user-defined type is just a single-parameter function that returns
TRUE or FALSE.
Look e.g. here <http://www.rapideuphoria.com/type.zip> for a file that
contains a collection of useful global types. Works fine. smile

Are you really sure that you did include the right file?

Regards,
   Juergen

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

3. Re: Can types be global

Make sure typechecking is not disabled within the include file or any files it
includes.

Chris Bensler
~ The difference between ordinary and extraordinary is that little extra ~
http://empire.iwireweb.com - Empire for Euphoria

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

4. Re: Can types be global

Chris Bensler wrote:
> 
> Make sure typechecking is not disabled within the include file or any files
> it includes.
> 
> Chris Bensler
> ~ The difference between ordinary and extraordinary is that little extra ~
> <a href="http://empire.iwireweb.com">http://empire.iwireweb.com</a> - Empire
> for Euphoria

Would that be without type_check? If so how can I override this.
I can't find that in there but I would like to be sure with an override.

Don Cole

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

5. Re: Can types be global

Juergen Luethje wrote:
> 

> Of course can types be global.
> A user-defined type is just a single-parameter function that returns
> TRUE or FALSE.
> Look e.g. here <<a
> href="http://www.rapideuphoria.com/type.zip">http://www.rapideuphoria.com/type.zip</a>>
> for a file that
> contains a collection of useful global types. Works fine. smile

I downloaded your type.e

global type upper_char (object x) --I was told that if statements took more
---time.
   if integer(x) then
      if x <= 'Z' then
         return x >= 'A'
      else
         return find(x, "ÄÖÜ") != 0
      end if
   end if
   return 0
end type


Are you really sure that you did include the right file? Yes, have other procedures and functions in there that work.

Regards,
Juergen

Don Cole }}}

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

6. Re: Can types be global

don cole wrote:

> Chris Bensler wrote:
>> 
>> Make sure typechecking is not disabled within the include file or any files
>> it includes.
> 
> Would that be without type_check?

Yes.

> If so how can I override this.
> I can't find that in there but I would like to be sure with an override.

with type_check

see <http://rapideuphoria.com/refman_2.htm#62>

Regards,
   Juergen

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

7. Re: Can types be global

don cole wrote:

> --I was told that if statements took more ---time.

This is not generally true, but depends on the concrete situation.
E.g. it should be considered, that in Euphoria short-circuit evaluation
<http://rapideuphoria.com/refman_2.htm#shortcir> -- which can save time --
only works in a statement that uses if, elsif, or while.

Regards,
   Juergen

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

8. Re: Can types be global

Juergen Luethje wrote:
> 
> don cole wrote:
> 
> > Chris Bensler wrote:
> >> 
> >> Make sure typechecking is not disabled within the include file or any files
> >> it includes.
> > 
> > Would that be without type_check?
> 
> Yes.
> 
> > If so how can I override this.
> > I can't find that in there but I would like to be sure with an override.
> 
> with type_check
> 
> see <<a
> href="http://rapideuphoria.com/refman_2.htm#62">http://rapideuphoria.com/refman_2.htm#62</a>>
> 
> Regards,
>    Juergen

You cannot override with or without type_check.
You can turn typechecking on or off at different points in your program, but if
a file contains a with/out type_check statement, there is no way to override that
with an opposing statement.

What happens is that the part of code that is marked as 'without type_check'
will never get type_checked, until the 'with type_check' statement is
encountered, then all code until the next 'without type_check' or the end of the
file, will be type_checked.

Clear as mud, right? :P

Chris Bensler
~ The difference between ordinary and extraordinary is that little extra ~
http://empire.iwireweb.com - Empire for Euphoria

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

9. Re: Can types be global

Chris Bensler wrote:
> 
> Juergen Luethje wrote:
> > 
> > don cole wrote:
> > 
> > > Chris Bensler wrote:
> > >> 
> > >> Make sure typechecking is not disabled within the include file or any
> > >> files
> > >> it includes.
> > > 
> > > Would that be without type_check?
> > 
> > Yes.
> > 
> > > If so how can I override this.
> > > I can't find that in there but I would like to be sure with an override.
> > 
> > with type_check
> > 
> > see <<a
> > href="http://rapideuphoria.com/refman_2.htm#62">http://rapideuphoria.com/refman_2.htm#62</a>>
> > 
> > Regards,
> >    Juergen
> 
> You cannot override with or without type_check.
> You can turn typechecking on or off at different points in your program, but
> if a file contains a with/out type_check statement, there is no way to
> override
> that with an opposing statement.
> 
> What happens is that the part of code that is marked as 'without type_check'
> will never get type_checked, until the 'with type_check' statement is
> encountered,
> then all code until the next 'without type_check' or the end of the file, will
> be type_checked.
> 
> Clear as mud, right? :P
> 
> Chris Bensler
> ~ The difference between ordinary and extraordinary is that little extra ~
> <a href="http://empire.iwireweb.com">http://empire.iwireweb.com</a> - Empire
> for Euphoria

O.K. 



-----------include file (mygets.e}

global type caps(integer x) return x >= 'A' and x<= 'Z' end type

---------page1.e include myfile.e if caps(list[2][$]) then here I get error 'caps not declared' ---------main program

include mygets.e include page1.e


Would without type_check cause this error?

Thanks, Don Cole }}}

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

10. Re: Can types be global

Chris Bensler wrote:

> Juergen Luethje wrote:
>> 
>> don cole wrote:
>> 
>>> Chris Bensler wrote:
>>>> 
>>>> Make sure typechecking is not disabled within the include file or any files
>>>> it includes.
>>> 
>>> Would that be without type_check?
>> 
>> Yes.
>> 
>>> If so how can I override this.
>>> I can't find that in there but I would like to be sure with an override.
>> 
>> with type_check
>> 
>> see <<a
>> href="http://rapideuphoria.com/refman_2.htm#62">http://rapideuphoria.com/refman_2.htm#62</a>>
>> 
>> Regards,
>>    Juergen
> 
> You cannot override with or without type_check.
> You can turn typechecking on or off at different points in your program, but
> if a file contains a with/out type_check statement, there is no way to
> override
> that with an opposing statement.

This is absolutely right, of course. It seems that I was somehow confused
yesterday. Thanks for un-confusing me. smile

Regards,
   Juergen

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

11. Re: Can types be global

don cole wrote:

> -------------include file (mygets.e}
> 
>  
> global type caps(integer x)
>   return x >= 'A' and x<= 'Z'
> end type
> 
> 
> -----------page1.e
>  include myfile.e
>  if caps(list[2][$]) then-- here I get error 'caps not declared'
> -----------main program
> 
> include mygets.e
> include page1.e
> ---------------------------
> Would without type_check cause this error?

No. Using "without type_check" just switches type checking off, it does not
cause and error at all.
The point here is, that you have to include "mygets.e", _before_ you use
any code located in this file. So your program should look like this:

-------------include file (mygets.e}

global type caps(integer x)
  return x >= 'A' and x<= 'Z'
end type

-----------page1.e

include mygets.e
include myfile.e

if caps(list[2][$]) then-- here I get error 'caps not declared'

-----------main program

include page1.e

---------------------------


Regards,
   Juergen

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

12. Re: Can types be global

On Wed, 29 Nov 2006 22:22:32 -0800, don cole <guest at RapidEuphoria.com>
wrote:

>Would without type_check cause this error?
No. Absolutely not.
Have you yourself created three/four small files like the code you
posted and tested it? If not, why not?

Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu