Alternate declaration syntax
Hans W. Uhlig
huhlig at gmail.com
Sat Apr 12 00:26:23 PDT 2008
Scott S. McCoy wrote:
> I see where you're going with this suggestion, but we don't need to
> change that much to have multiple return values, either with the
> existing syntax, or the syntax I previously suggested. in the last
> thread:
>
> public const const(int), const(float) foo (const int foo);
>
> (syntax I suggested)
> public const int:const, float:const foo (const int foo);
>
> This is already quite possible, syntactically, with minimal
> restructuring of method declarations.
>
> Also, with syntactical additions such as keywords like "throws" or
> "returns", the additional punctuation seems unnecessary.
>
> But if you are going to affix a method declaration with multiple
> possible types of statements (throws, returns, whatever else) keywords
> seem to make more sense than punctuation.
>
> Cheers,
> Scott S. McCoy
>
> On Fri, 2008-04-11 at 11:41 -0700, Hans W. Uhlig wrote:
>> Koroskin Denis wrote:
>>> On Fri, 11 Apr 2008 21:26:24 +0400, Hans W. Uhlig
>>> <huhlig at clickconsulting.com> wrote:
>>>
>>>> Ok, Posting to the main forum so it doesn't get lost in the const stuff.
>>>>
>>>> Perhaps a slight variation to the C declaration might be in order,
>>>> since I know that multiple return values are wanted, a simple and
>>>> readable syntax for inheritance is needed (using : as an inheritor
>>>> does not make code more readable) try this out and see if it makes it
>>>> clearer
>>>>
>>>> <modifiers,...> <identifier> <properties,...> {...}
>>>>
>>>> such that:
>>>> const foo(const int, const double) §
>>>> throws barExtension §
>>>> returns const int, const float
>>>> {
>>>> // ... code ...
>>>> }
>>>>
>>>> same for classes:
>>>>
>>>> const class foo § extends bar {
>>>> const int x;
>>>> pure foo(const int, const double) § returns invariant string;
>>>> // ... more code ...
>>>> }
>>>>
>>>> (Note: § is used as a divider because no one uses it for anything in
>>>> programming and I didn't want to start an argument over : or | or ; or
>>>> any other punctuation being used elsewhere and being bad, quite
>>>> possible punctuation wouldn't be neccessary)
>>>>
>>>> It looks like a hideous cross between java and visual basic but it is
>>>> clean, readable, simple to machine parse(I think) and descriptive.
>>>> using slightly longer keywords makes a language a little more verbose,
>>>> but it also makes it readable. if you want to use punctuation for
>>>> everything you get what happened to perl when someone got a little too
>>>> creative
>>>>
>>>> `$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
>>>> $!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$..++;
>>>> $_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
>>>> ;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
>>>
>>> Yeah, except that I (and many others) don't have that sign on my
>>> keyboard <g>
>>> Did you mean $, not §? IMO, colon serves the purpose better.
>>>
>>> Other than this, I like Jave-style throwable list. I believe it makes
>>> DBC more powerful.
>>> I would also like to see thread safety attribute as well, but it could
>>> be a pain for compiler to verify.
>> I used § as a placeholder, I was looking more for the syntax then the
>> punctuation I prefer using a : or none at all if possible. I just used §
>> to stem off a horrendous debate on the merits and flaws of the colon.
>
I agree. The syntax I suppose was to make it look more distinct from
other methods. I dont like tacking on const to the begining of
everything because when developing const functions returning touples you
end up with 4 or 5 consts and it gets really confusing. I agree the
simple keywords would be best as this eliminates all of the ambiguity in
the syntax and also makes it alot easier to read.
More information about the Digitalmars-d
mailing list