Re: Rob: Q: Constant Scope

new topic     » goto parent     » topic index » view thread      » older message » newer message

Robert Craig wrote:

>
>
>posted by: Robert Craig <rds at RapidEuphoria.com>
>
>Vincent wrote:
>  
>
>>The ref manual says:
>>"Constants may not be declared inside a subroutine." 
>>"Constant declarations must be outside of any subroutine. Constants can
>>be global or local, but not private."
>>
>>Can you tell me why you made the language support only constant declera-
>>tions at top-level, and not support it at routine level (private scope)?
>>I'm just curious on why made it this way. What are the disadvantages?
>>
>>I'm trying to figure out whether or not I want to add this functionability
>>into my
>>custom interpreter, and I wanted to know what you thought about
>>it.
>>    
>>
>Here's something I wrote a few years ago, that discusses this issue
>and a few other contentious issues:
>
>>http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=2&fromYear=7&toMonth=2&toYear=7&postedBy=rds&keywords=constant+scope+routine
>
>In language design there is rarely a "right answer".
>Things are very subjective.
>
>  
>>Another question... Is there anyway I can use global variables in
>>Eu2C translated/compiled DLLs, being able to use define_c_var()?
>>If not, could you consider, adding support for it in the next
>>release? I tried making an example but it didnt work, maybe I did
>>somthing wrong?
>>    
>>
>I have an example of define_c_var() in a Linux demo.
>It lets the Euphoria program access a C variable in a shared library.
>I don't know how well that works in the Windows world.
>I think in Windows, it might only be routines that can be 
>exported from a .dll, not variables. Maybe someone else here has tried it.
>
>Regards,
>   Rob Craig
>   Rapid Deployment Software
>   http://www.RapidEuphoria.com
>
>
>
>
Copied from the post:

    There's an optimization which is near the top of my list, that would
     eliminate the need for copy-on-write in many cases. Consider:

               function sort(sequence s)

                   s[i] = ...
 
              end function

               sequence x
               ...
               x = {5,6,7,8}
               ...
               x = sort(x)

     It would be possible to detect that the value of x, as passed to
     sort(), will never be needed again. The implementation could then
     arrange that the value passed to sort() will have only *one* 
     reference count (from s), rather than 2 (from x and s). This would 
     eliminate the need for a copy.

I think that this is a very reasonable optimization that eliminates most 
of the arguments for modifying "pass by reference" values.  Have you 
ever implemented it?

-- 
==============================
Too many freaks, not enough circuses.
j.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu