May 02, 2024, 06:14:14 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


{ } brace subsitutes?

Started by kryton9, May 14, 2006, 01:33:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kryton9

I never cared for using { } as in c and other languages. It is too confusing when you have so many nested operations. I always thought having a for next, if endif, while endwhileÂÃ,  etc was better and easier to read in code and troubleshoot errors.

Is there a way I could define my own substitutes for braces in Aurora using such syntax I like?

Parker

If you have a preprocessor you can do a Pascal-like BEGIN/END block:
#define begin {
#define end }

sub x(),int
begin
    if x = 1
    begin
        x = y;
        y = z;
    end
end


And sometimes people write comments after the braces when using C, I agree it can get confusing sometimes.
if( x = 1 )
{
    y = 2;
    // Do some complex operations here
} //endif

kryton9

Thanks Parker, the preprocessor tip is exactly the type of thing I was looking for.

Parker

You can't do it currently though, since #define only defines integer constants. What I meant is you'd need an external preprocessor to run the files through, which I may do over the summer.

LarryA

I was thinking the same thing yesterday as I found myself (gulp) exploring the MS Visual Basic.net language, as my current Basic is getting worrisome.  I've tried for years to cozy up to C-like syntax... i just can't get comfortable with it... seems like I have to slow down to a crawl and very carefully analyze it.  It's hard enough to read other peoples' sample code (or even code I've done a long time ago) without adding what is, for me, a syntax barrier.

I've written language converters before (ironically I wrote the converter in a C-syntax language), and while a true Basic syntax might be difficult to achieve, I can see where a substantial Basic "feel" (like VB.net attempts) might be doable with an unofficial "Aurora Basic" preprocessor.

Although I've read every post here since the site started, for the day I may eventually use Aurora, I haven't pulled the trigger and changed yet.  I fear for my life if I have to think in both C syntax and OOP concepts... I'm afraid my head might explode.
"Aerodynamics are for people who can't build engines." -- Enzo Ferrari
"Turbochargers were for people who can't build engines" -- Keith Duckworth

Mike Stefanik

I doubt that it would be hard for Paul to add "begin" and "end" statements ala ALGOL as aliases for the braces. It'd just be a matter if that's something that he would be interested in doing.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Ionic Wind Support Team

I guess it depends on your background ;)

I prefer the braces and always found all of the extra keywords in BASIC as unnecessary and redundant.  { } just groups statements together in a block.  Scintilla (our editor) lets you fold those blocks by clicking on the '-' in the margin. You can use comments on closing braces if you get lost.  Indentation also gives you a clue.

Aurora is an OOP language and I have no plans on creating another procedural BASIC language.  IBasic was enough for me. There are those that try and argue that OOP is not effective, my answer is that it is something you have to spend the time and learn before making judgements. 

I hate to see programmers that have never worked on a large scale (> 5 million lines) project bash methodologies.  For me, and countless other developers, OOP is a natural application to solving programming problems.  IBasic wouldn't exist without it, IBasic Pro wouldn't exist without it, and no you are not forced to use it in Aurora.

Is it easier to write a small (< 1000) line program in BASIC.  Perhaps, perhaps not.  It all depends on the knowledge and the skills of the programmer in question.  Will Aurora be easier to write that small program?  Yes, we think so.  With the features for the IDE and language that are planned it will be very easy.

Stick around and watch it grow ;)

Paul.
Ionic Wind Support Team

LarryA

Please note I'm not bashing C syntax or OOP... just stuck in my old ways and my brain is remarkably stubborn about adapting.  I will stick around, and probably take the plunge at some point... I'll just comment my code more like Parker mentioned...

if( )
{ //then
.
.

else
if( )
{ //then
.
.
} //endif
} //endif

"Aerodynamics are for people who can't build engines." -- Enzo Ferrari
"Turbochargers were for people who can't build engines" -- Keith Duckworth

J B Wood (Zumwalt)

OOP is a cake walk. Truthfully, you will use {} more in OOP languages than anything else. It exists in all java, all forms of C, and eventually it will creep into vb.net (don't ask me about that one, its an ugly debate), but the truth is, {} is by far the easiest way to handle grouping.

Eventually I can see Aurora auto tabbing based on {}, same as C#, it took me all of 1 day to figure out the syntax of Aurora, thats because I not only have vb.net background, but I have c and c# background, the world is moving twords c#, and this is just a native progression in the chain.

Why fight against the tide? Dropping the end if, whend, etc, and just use the group, gives the assumption of those, and allows for tidier code and easier structuralization.

I have lived in the world of old school vb and c, asp and aspx (asp.net), vb.net and c#, some java, cgi, delphi, old school pascal, etc. begin and end are human friendly words, but they are totally anoying, { = assumed begin of block, } = assumed end of block, all this lanuguage needs is what is identical in c#, witch is auto formatting. It desperately needs Try / Catch / Finally statements. Where it seems to be lacking the most is step-into procedure with real results vs take your best guess at what is wrong here.

This is alpha, and damn, I am impressed for a translation language to be his forgiving, this early in the game. You have no clue the potential this has for using outside dll files, I am stoked just on that one feature alone. I have like a bizillion dll's lying around that I have written for odds and ends projects that I can now cleanly bring together into a nice little toolkit package without having to guess at marshalling, if you have ever had to deal with marshalling, you would understand my pain.

Well thats my coppers worth. Anyway, cheers, I am along for the ride, will hopefully contribute to the project once I figure out this source.

Parker

There are ways to handle the {} braces without actually using them in BASIC, I've seen it done. And I also know that a syntax doesn't mean anything, I know of BASIC languages that are more powerful than C, and C style languages that are less powerful than the commonly thought weak BASIC, but Aurora isn't being built that way. I could very easily compile a C program that uses THEN, ENDIF, WEND, ENDSUB, etc as preprocessor defines, but what's the point?

If you search codeproject for the Db (d flat) language, you'll see a joke made about using different braces to distinguish between endif, next, etc: while( x ) {{{ stmt; }}}, or {} ... {}.

You can use comments though, it's more common with preprocessor in C:
#ifndef x
// some code here
#endif /* !defined( x ) */

if( !x )
{
// some code here
}//endif

which is what I recommend if { } make you lost.

I use column selection when I need it (hold Alt and drag with the mouse), because I always put braces on their own line and indent the inside.

mrainey

Some text editors (UltraEdit is one) will highlight matching braces.  Click on an open brace, the matching close brace is color-highlighted.  Or vice-versa.


Does Scintilla offer something like that?
Software For Metalworking
http://closetolerancesoftware.com

Ionic Wind Support Team

Scintilla does have brace hilighting.  Haven't played with it yet though.
Ionic Wind Support Team

Parker

Yeah, scintilla does it, but Aurora's IDE doesn't have that yet. I haven't looked into it yet also, I'll have to do that just for my information.

Bruce Peaslee

Quote from: Ionic Wizard on May 14, 2006, 07:45:51 PM
Scintilla does have brace hilighting.ÂÃ,  Haven't played with it yet though.

That would be useful. I wonder if any of the developers have any experience with Scintilla, to the point they can work on the IDE.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

Actually... ;)

I've been writing an IBasic lexer and demo program for scintilla. Only problem is I've never used MFC.

Ionic Wind Support Team

Why use MFC?  You can use Scintilla in any language, including Aurora.  Alyce Watson wrote a small IDE using Scintilla but the code is gone now that the 'other' site was hacked.
Ionic Wind Support Team

Parker

Because the current Aurora IDE is written in MFC. But an IDE written in Aurora is a nice idea.

seberbach

The only thing I can't see wrong with braces is that they are so small and they all look alike:}){|{(}-|[{-}{}){

Must be getting too old- 8)

Parker

With an IDE that implements all (or a good amount) of scintilla's features, you could turn up the font for braces only, and matching brace highlighting would only match { with }, etc.

Bruce Peaslee

Quote from: Parker on May 15, 2006, 09:21:32 AM
... But an IDE written in Aurora is a nice idea.

I think so. Although I do not have any experence in this area, I'm going to take a look at it. I guess if I want page breaks, I'll just have to implement them myself. ÂÃ,  ;)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

Bruce, I started an IDE written in Aurora when I said that, maybe we can set up a topic in the developers area and everyone can work on it.

Bruce Peaslee

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles