Re: Wishlist

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

On Monday 25 June 2001 13:37, kbochert at ix.netcom.com wrote:

>    MY WISHLIST:
>
> 1-- Variable initialization:
> 	integer x = 5
> 	...
> 	function foo ()
> 		sequence s = ""
> 		...

Yes, no doubt about it.  I continually get messages such as: 
test.exu:3780
variable s has not been assigned a value
--> see ex.err

because I declared, but forgot to initialize, s. Were it possible to do this 
on the same line as the declaration, I might just remember. Also, it makes 
code clearer.

> 2-- continue statement:
> 	goes to start of for or while loop

There are instances where this can simplify code, which otherwise 
would require deeper if... then nesting. A qualified yes from me.

> 3-- Pass-by-reference:
> 	procedure foo (reference p1)
>		...
> 	integer x
> 	foo (&x)	-- x may be changed

Useful, but the wrong syntax, in my opinion. 
You have lost the type of p1, so it is in effect always treated as 
an object.  No more automatic type checking.
Perhaps better would be to use:
procedure foo (integer  x)
 .... blah...
    x +=1 

then call it like this:  foo (varying x) 
-- I know, it sounds too much like COBOL.:{

There's too much chance of forgetting the &, or including it 
accidentally, and having "unexpected results". Plus its meaning 
is not immediately obvious, and worst of all , it looks like C!

However, this has been requested before, and Rob has not shown 
much interest it implementing it, which leads me to believe that 
something about the internal workings of Euphoria would make 
that operation either difficult, or wasteful of time or memory.
(in other words, not a good tradeoff)

> 4-- Enhanced '?'
> 	If a sequence contains all ascii characters, output it as string.

Amen. And use the same function in the debugger.

> 5-- Enhanced standard library(s), possibly built-in
> 	string functions
> 	regular expressions
> 	isAscii () etc.
> 	containers

Yep. These things already exist, thanks to all the contributors. 
It would just be a matter of organizing them a bit, documenting
and stamping  them all. Maybe Rob doesn't have time for all that.
All volunteers take one step backward.

> 6-- slicing shorthands:
> 	seq[2..]     =>  seq[2..length(seq)]
> 	seq[i..-3]   =>  seq[i..length(seq-3)]
> 	seq = [2..]  =>  seq = seq[2..length(seq)]
> 	seq += "a"   =>  seq = append (seq, "a")

Also frequently suggested.  Your version adds a possible
syntax checking problem, in that seq[2..] could *easily* be a typo - you just 
forgot to finish the range. 

Therefore, I suggest using a character that isn't used for anything 
else - the tilde - to indicate "to end" or "from beginning", as 
in seq[2~] or seq[~14} -- seq[~] would be an error.
Means the same to me, but it's really hard to confuse the 
tilde with two dots, or to type a tilde when you meant to 
type ..4.

And as Carl pointed out, there is a definite problem with the 
seq += "a",  a notation that confuses me anyway. It looks 
like a math function, maybe you want to add the ascii value of 
"a" to each atom in the sequence? 'append' may be wordy, 
but at least its meaning is clear. 

> 7-- File-local definitions should override globals

Breaks too much code, unless you're talking about adding a 
'local' keyword, as in 'local integer x', in which case I'm in 
favor of it.

The question would then become, is global x still accessible? 
Seems not, at least not without a means of qualifying them, 
local.x = 12, or my:x = 12 (urk - ever seen perl? You need 
a keyboard which has a 'my' key) 

> 8-- Common utilities:
> 	boolean
> 	FALSE
> 	TRUE
> 	STDERR
> 	STDIN
> 	STDOUT

Why not? If it weren't for the fact that just about everybody has already 
defined TRUE and FALSE in their code, this would be fine.
Which still leaves me wondering why they weren't an integral part 
of Euphoria from the beginning?
 
> 9-- function indexing
> 	s = command_line()[2]

Another one that may be difficult to implement, but there are sure a 
lot of places where such a thing would be helpful.
year = date()[D_YEAR], for example.

But this doesn't go far enough, IMHO.
Here's the kind of code we really need a replacement for:
sequence now
now = date()
now = now[2] & now[3] & now[1]+1900

All that just to get the Month, Day and Year! Sheesh....
how about:

now = date(M,D,Y) 

where M,D, and Y have a special meaning within function date()
independent of any M, D or Y we may have declared in 
our programs?

> 10- Namespaces
> 	include get.e as G
> 	x = G:get ()

Enought has been said about this one.

> 11- pathlists
> 	command line and/or .cfg file gives search paths
> 	for include files like: ".;c:\mylibs"
> 	SO that executing 'exw prog args' would cause Euphoria to
> 	check 'prog.cfg' for pssible include paths.

OK. That hasn't been a problem for me, but perhaps it has for others. 

> 12- flags
> 	command line and/or .cfg file gives flags
> 	exw test warn=3	-- run and set 'warn' to 3
> 	test.cfg:
> 		warn = 6	-- default 'warn'
> 		srcpth = ".;c:\temp"
> 		...
> 13- def
> 	replaces function or procedure

Don't like this. There are very good reasons for having functions and 
procedures as entirely separate beasts.  def is not definitive enough for 
me.

> 14- structures
> 	a sequence with named and typed indexes.
> 	struct X {
> 		integer a,
> 		sequence b
> 		}
> 	struct X a        => sequence a a = {0,""}
> 	a.b = "?"         => a[2] = "?"
> 	s = append(s, X)  => s= append(s,{0,""})

Apparently un-doable with Euphoria as it stands. 
As far as I have been able to determine, there's no way to retain 
the type of a member of a sequence.  So type checking items 
within a sequence wouldn't be possible. 

That still leaves the pressing need for a convenient way to 
REFER to members of a sequence, as you mention above.

> 15- Block comments

Yes, but let's improve on that: 
Here's what I find myself doing.
-- I write several lines of text, either a disclaimer, copyright, or such, 
-- to appear as comments. Later I need to put this same text into 
-- a window, or display it on the screen..

In its form as comments, I can't do that. I have to write it all over 
again, using 
"quotes, line feeds, \ttabs, and continuation characters to assign \n" & 
" the text to a variable. \n\n" 

Now, this is not a big thing, but why not simply have a command 
(the keyword is up for discussion) which in effect says:  Euphoria, 
everything from this point on until the end command is to 
be treated like the <pre>  </pre> tags in html - a preformatted piece 
of text.  Assign it to the variable specified, and move on - there's noting 
to see here.....
Example:

pretext disclaimer =
  This program is copyright 2001 by Irv Mullins <irvm at ellijay.com> 
  who bears no responsibility for its use. If your hair falls out, your 
  cat gets pregnant, or your kids get poison ivy, it's not my fault.

   So there!
end pretext

Everything, including the leading spaces and linefeeds, gets copied 
as is into the variable 'disclaimer', to be used where necessary.
It's put in once instead of twice, and in more readable form, to boot.

> 16- Exceptions
> 	throw () causes returns until caught
> 	much like Java 'unchecked' exceptions.
>
> 	function x ()
> 		throw (type, arg)
> 	...
> 	function y ()
> 		...
> 		return 0
> 	catch (type)
> 		...
> 	end

Such a thing is needed. Maybe there is an even better way?

> 17-  Automatic 'Result'
> 	Have each function automatically declare the object 'Result'
> 	which is returned by default. (Much like Eiffel).
> 	Then the following is legal
> 	function pi ()
> 	    Result = 3.14
> 	end function

I'm not sure I understand the advantage this has over simply  
putting 'return 3.14' as the final line in the function. Please elaborate.

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu