Millsa Erlas wrote:
I have thought of an interesting idea that may allow Perl 6 to make the
$, @, and % optional on many uses of variables. This involves simply extending the function namespace to include all kinds of structures, and thus the function namespace does not require symbols, they are optional.

The intention here is not to eliminate $, @, % and friends, just make them optional! I believe people should be able to make the choice as to which way to do things, we should give the programmer as much freedom and as any many ways to do things as possible, not constrain them but empower and free them from restrictions.

Also, a goal I have tried to follow here is to implement this feature without affecting the existing usage grammar and rules of the Perl 6 language at all. This is a good goal i believe, my intention is just for this to be an additional extension to Perl 6, not change its existing grammar and parsing rules at all, just expand upon it. Perl 6 is a great language and I like what has done so far. This is not an attempt to change what has already been defined, but rather provide an additional usage.

These are just some initial ideas, they may be able to be improved upon, or benefit from refinement.

**Subroutines

sub hello {
print "hello!\n";
}

#**Arrays
#Define
array hello=("1", "2", 3");

#in Array context:
@array=&array; #or
@array=array array;

#in Scalar context:
$element=array[1]; #or
$element=scalar array[1];

#**Hashs
#Define
hash hash1=(hello=>"hello1", hello2=>"hello2");

#In hash context=
%hash2=&hash1; # or
%hash2=hash hash1;

#scalar context
$hello=hash{hello}; # or
$hello=scalar hello{hello};

#**Scalars

#Define
scalar hello="hello";

#Scalar context

$hello=hello; # or
$hello=scalar hello;

#**References
#Make reference
scalar ref=\&hash; #or
scalar ref=mkref &hash; #or
scalar ref=mkref hash hash;

#Dereference:

#Every ampersand after the initial one attempts to deference the
# one level of referncing:
%hash=&&ref;
# THis would unwrap a reference in a reference
%hash=&&&ref;

# Dereference a reference in a hash
%hash=&&hash{ref};

#or
# A deref keyword for convenience:
%hash=deref ref; #or
%hash=hash scalar ref; #or
%hash=hash hash ref;

This is just an initial sketch, it may need or benefit from refinement.

I think that implementing the features I have described above as a module of some sort rather than include it in core would be very reasonable and acceptable, I am in fact looking into ways of doing this. @, $, and % does indeed have its advantages and I should continue to remain avialable. I think some sort of module is a good route to go for offering alternative grammer, so I am happy with this solution.

Reply via email to