1. Wish List Again

Ditulis 28-5-00, 10:59 pake kalong



[1] For example,

   sequence cmd, thirdParam

   cmd=command_line()
   thirdParam=cmd[3]

  Why we cannot use:

   sequence thirdParam

   thirdParam=command_line()[3]

  It's easier.

[2] A function may not return a value
    (can be called as a procedure), eg:

    function writePos(atom num)
        if num >= 0 then
           ? num         -- no return
        else
           return num
        end if
    end function

    writePos( -5 )    -- no return value


[3] We can use undeclared variable, eg:

    -- -- ### (no 'object var1, var2, var3' )

    var1=1+2
    var2=var1*2
    var3=repeat(var2, 5)

    -- var1,var2,var3 are automatically declared as
    -- 'object' variable type



I  can  use no: [2] and [3] in visual basic, makes programming easier,
why not in euphoria?

Thanks.

(sorry if my english is bad)




--
Aku  mailto:aku4 at crosswinds.net   (dulu nono at bdg.starindo.net)

new topic     » topic index » view message » categorize

2. Re: Wish List Again

On Mon, 29 May 2000 13:24:18 +0700, Aku <aku4 at CROSSWINDS.NET> wrote:

>Ditulis 28-5-00, 10:59 pake kalong
>
>[1] For example,
>
>   sequence cmd, thirdParam
>
>   cmd=command_line()
>   thirdParam=cmd[3]
>
>  Why we cannot use:
>
>   sequence thirdParam
>
>   thirdParam=command_line()[3]
>
>  It's easier.


   Can not used because command_line() is a function that

   RETURNS a SEQUENCE. You can not index a FUNCTION.

>
>[2] A function may not return a value
>    (can be called as a procedure), eg:
>
>    function writePos(atom num)
>        if num >= 0 then
>           ? num         -- no return
>        else
>           return num
>        end if
>    end function
>
>    writePos( -5 )    -- no return value
>
>

  Must be procedure or function can not be both.

  If program calls writePos() how will program know if number is printed.

  Program can not see value printed. Good function would return zero if

  printed or num if not printed.

>[3] We can use undeclared variable, eg:
>
>    -- -- ### (no 'object var1, var2, var3' )
>
>    var1=1+2
>    var2=var1*2
>    var3=repeat(var2, 5)
>
>    -- var1,var2,var3 are automatically declared as
>    -- 'object' variable type
>
>
>
>I  can  use no: [2] and [3] in visual basic, makes programming easier,
>why not in euphoria?

  The only time that you can NOT do this if variable is OBJECT.

  Any other type of data you can use SEQUENCE

  ###( sequence var )
    var[1]=1+2
    var[2]=var[1]*2
    var[3]=repeat(var[2], 5)

>(sorry if my english is bad)


  Very good english

  Bernie

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

3. Re: Wish List Again

Aku writes:
> 1. thirdParam=command_line()[3]

> 2. writePos( -5 )    -- no return value

> 3. We can use undeclared variable, eg:

I would not completely rule out allowing 1 or 2 someday,
but I would rule out 3. Declaring your variables catches
subtle spelling mistakes that might take you hours of debug
time to notice. It also informs the reader of your code (i.e. you!)
what the possibilities are for that variable without having to
search for every place that the variable is used.

Languages that don't require you to declare
variables are not saving you any time in the long run (especially
if they don't complain about uninitialized variables, and quietly
"do you a favor" by setting them to 0 or "").

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

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

4. Re: Wish List Again

On 29 May 2000, at 11:17, Robert Craig wrote:

> Languages that don't require you to declare
> variables are not saving you any time in the long run (especially if
> they don't complain about uninitialized variables, and quietly "do you
> a favor" by setting them to 0 or "").

Except it's nice to be able to build variables with names you don't
know when you wrote the code. I get around this in Eu now by
making a var and then subsequencing it with tagged fields.

In mirc, this line:
set %didgreet.op [ $+ . $+ [ $gettok($address($nick,4),2,$asc(@)) ]
$+. $+ [ $chan ] ]  yes $ctime $nick

builds this var:

%didgreet.op.ts2-d17.yar.auracom.com.#fullmoon yes 959628528
Sam

So later on, i can test if the code greeted *anyone* at ts2-
d17.yar.auracom.com in that room, when, and what nick they used.
I can, using the same var access method, make a list of known vars,
known addresses, last seen times from that addy, etc.. In Eu, i
haveto declare the var, and build subsequences. Ok, not a problem
yet. But trying to access the var when it doesn't exist isn't a problem
in mirc because it returns $null , in Eu it's a bounds error.

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu