array parameters require extra brackets

BlitzMax Forums/BlitzMax Programming/array parameters require extra brackets

skidracer(Posted 2005) [#1]
Function dump(strings$[])
	For Local a$=EachIn strings
		Print a$
	Next
End Function
	
Dump(["bmx"])


but this code doesn't compile:
Dump ["bmx"]



MrCredo(Posted 2005) [#2]
local s$[]
Dump(s)

???


marksibly(Posted 2005) [#3]
There's not much I can do about this, as the compiler doesn't know whether you're indexing a 'Dump' array or passing an array to a Dump function.

It's just a compromise made to allow for 'bracketless' functions.


teamonkey(Posted 2005) [#4]
That's a bit of hardcore obfuscation isn't it? :)


Chris C(Posted 2005) [#5]
hang on you can't define an array thats the same as a function name...
So if theres a 'dump' function there cant be a 'dump' array


AntonyWells(Posted 2005) [#6]
Arrays could do with cleaing up in the docs. I still havn't managed to get multi-dimensional arrays to work.

I realise I could by asking here(I've had no need for them) but still. Docs should explain it clearly.


Russell(Posted 2005) [#7]
We all agree that the docs are, um, seriously lacking in many ways (the User Guide in particular, which on the home help screen says "User Guide - how to create programs in BlitzMax", does no such thing. In fact there are only a handfull of commands even mentioned!).

I believe multi-dimensional arrays are discussed here, though:
http://www.blitzwiki.org/index.php/Beginners_Guide_to_BlitzMax#Arrays

Documention, for some reason - despite its obvious importance, is often minimal or written from an expert programmer's point of view, rather than from a layman's point of view. I was hoping that this would be addressed by the time the official Windows release was, um, released.

I wrote a User Guide, but it is only about 60-70% complete ( http://www.geocities.com/amiga5k/BMGuide2.zip ).

It is in OpenOffice.Org format (which is free http://www.openoffice.org/ ).

Anyone who is interested in continuing the User Guide is encouraged to do so, especially the experts here who also know how to explain things to the average person... You know who you are!

Russell


Russell


Koriolis(Posted 2005) [#8]
hang on you can't define an array thats the same as a function name...
So if theres a 'dump' function there cant be a 'dump' array

That's true, but fixing the problem means introducing a special case for when 'Dump ["bmx"]' appears alone on a line (in which case it's parsed as a function call) and when it appears in an expression (in which case it's parsed as an array indexing).
This would not be very consistent. Actually there is already a similar case in the BlitzMax : '=', which is parsed either as the assignment operator or as the equality test.
Given that we already have such a case, we could say "go for it", one more is no problem but actually I realy, really don't like these inconsistencies.
Just my 0.02$