1. RE: Hello

Xanax,

Welcome to the community!  

Yep, this one has been discussed numerous times on this list.  Rob Craig 
has said that the early release of V2.4 will be out soon, don't know if 
this will be addressed or not.

Jonas
xanax at bellsouth.net wrote:
> Im new to this list and like the Euphoria language.
> 
> only wish we could do this:
>     integer var = val
> instead of
>     integer var
>                var = val
> 
> Newby,
> Xanax
> 
>

new topic     » topic index » view message » categorize

2. RE: Hello

Greetings, Xanax. I hope Rob doesn't mind if I copy his excellent 
explanation as to why "integer var = val" isn't permitted in Euphoria.

Also, don't hesitate to use the "mailing list search" on the Euphoria 
website, as answers to this and many other questions can be found that 
way (that's how I found this).

Cheerios,
   Gabriel


From: Robert Craig <rds at RapidEuphoria.com>
Subject: Re: A question about certain language features

Ed Davis writes:
> 1) Variables can not be initialized when declared, but
> rather, must be initialized via an assignment statement.
> Based on other languages, this seems like one of those
> convenience type issues.  Is there some programming
> philosophy that says that an initialization in a declaration
> is a 'bad thing'? 

It's not a "bad thing". In fact it seems like an obvious bit of
convenience that couldn't possibly cause any harm.
Since a lot of people have asked lately, here is my
(very subjective) opinion on the matter. I've also
included your question about private constant declarations.

Suppose we allow:

#1.  variable inits:  integer x = 99

and if you allow #1, it would be even stranger (than it is now)
not to allow:

#2.  constants declared inside a routine for use within that routine 
only

So now you've got routines that start off with an arbitrary mixture
of variable and constant declarations, some of the variables
are assigned an initial value, some aren't. The only visual difference
between a constant declaration and a variable declaration, is
that people have to remind themselves that "constant" is not a type,
it's something totally different. e.g.

function aaa(integer z)
object d, e, f
constant a = 99 * foo()
integer b = 99 + bar() * 7, h, i, g = 777
atom c
g += 1
h = g
etc.

Now whenever you examine a routine, instead of quickly skipping
over the declarations, you will have to carefully
wade through all the declarations, some containing
function calls and complicated expressions, to figure out 
which code is going to be executed. 

Simply stated, you've got executable code hidden amongst the
declarations, and constant declarations now look no different from 
variable declarations. Things used to be neatly separated and
you could visually skip the declarations when mentally tracing
execution. Now things are jumbled together. 

I once spent hours debugging something in another language,
simply because the author of the code had hidden a variable
declaration with initialization in amongst 20 or so other declarations.
I just couldn't "see" that the subroutine did not really "start" where 
I thought it did. It actually started in the middle of the declarations
somewhere.

I like it better the way it is. You could argue that I don't have to use 

variable inits if I don't want to. You could argue that I don't have
to use goto if I don't want to. A language does not exist just
to serve the isolated programmer. It exists to serve a community
of programmers. In situations where it really doesn't matter 
how something is written, I think there are advantages to 
reducing the number of choices.

[...]

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

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

3. RE: Hello

On 9 Dec 2002, at 16:53, Jonas  Temple wrote:

> 
> Xanax,
> 
> Welcome to the community!  

Yeas, welcome to the community, Euman!

Kat

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

4. RE: Hello

Derek Parnell wrote:
> Ahhh, so that's why we can't use executable code to assign some 
> constants
> and not others, and why we can't mix executable code and variable
> declarations outside of routines. Its all so clear now.

Hmm, my "sarcasm detector" appears to be going off the scale here... :p

I'm not sure I entirely understand your comments about assigning to 
constants. However, regarding variable declarations and assignments 
outside of routines, obviously Euphoria follows different rules outside 
routines than within them. Which is confusing enough. Allowing "integer 
var = val" outside of routines but not within them would simply be 
adding confusion to confusion. And Rob's stated reasons for not allowing 
"integer var = val" within routines seem perfectly sensible to me.


Cheerios,
   Gabriel

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

5. RE: Hello

petelomax at blueyonder.co.uk wrote:
> Hello all,
> 
> Just joined and already here is my first bozo question:
> 
> I notice there is no float() function.
> Am I right in assuming that is the only distinction between the atom()
> and integer() functions? I tested it and it seems to be true.
> integer('a') returns true as I kind of expected. (& accept to be true)
> 
> Just being curious.
> 
> Pete

Yes.  There are only two basic types of data: atoms and sequences. 
Somewhere in the documentation Mr. Craig says that he chose the word 
'atom' for the basic data type because it conveys the idea of ultimate 
irreducible items of information upon which the whole program rests.  
Sort of that on which no more divisions and analysis can be made.  This 
raises an interesting question, concerning the relation of this theory 
to bits, which undoubtedly are the indivisible elements of any computer 
program, and whether the atoms can be used to program at a low enough 
level so as to make Euphoria the next systems programming language.  



http://communities.msn.com/Semioticphilosophy

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

6. RE: Hello

petelomax at blueyonder.co.uk wrote:
> Hello all,
> 
> Just joined and already here is my first bozo question:
> 
> I notice there is no float() function.
> Am I right in assuming that is the only distinction between the atom()
> and integer() functions? I tested it and it seems to be true.
> integer('a') returns true as I kind of expected. (& accept to be true)
> 
> Just being curious.
> 

Pete:

  You can create your own float types by doing this:

global
type float( atom data )
  return ( data >= -3.4E38 and data <= 3.4E38 )
end type
--
global
type double( atom data )
  return ( data >= -1.7E308 and data <= 1.7E308 )
end type
--

  Then if you can use the float types just like other programming
  langauges.

float f1, f2, f3

  f1 = 3.1
  f2 = 2.77
  f3 = f1 + f2
  
Bernie

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

Search



Quick Links

User menu

Not signed in.

Misc Menu