Results 1 to 3 of 3

Thread: Coding Style Ideas

Share/Bookmark
  1. #1
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    61
    Posts
    3,869
    Rep Power
    397

    Coding Style Ideas

    Guys, I did a test to see if this would work, and glad it does. I am using some ideas from php and dark basic pro. Well in php all the variables have the $
    and in DarkBasic Pro a common way to identify float variables is with a #. I think this idea of identifying the type of variable with the variable name and symbol is nice, however the way it is in c, I don't care for as it is in the front of the variable there are so many types.

    The idea here is $ would be at the end of string variables, the # at the end of float variables and variables without any symbol are integers.

    Also I was thinking for subs it would be

    CapFirstLetter and no () it is a subroutine.
    CapsFirstLetter() with () means it is a function

    capFirstLetter would be an integer variable
    capFirstLetter$ a string
    capFirstLetter# a float
    %capFirstLetter is a constant

    What do you guys think? If you have any other ideas would like to read them here.

    USES "CONSOLE"
    dim float# as double = 123.45
    dim s$ as string = "Thin Basic"
    dim i as integer = 5
    
    Console_Write( "the float value is " & Str$(float#) & $CRLF)
    Console_Write( "the string value is " & s$ & $CRLF)
    Console_Write( "the integer value is " & Str$(i) & $CRLF & $CRLF)
    Console_Write( "Any Key to Exit" & $CRLF)
    Console_WaitKey
    
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,760
    Blog Entries
    3
    Rep Power
    689

    Re: Coding Style Ideas

    Hi kryton,

    I don't understand few things.
    When subroutine will be word with no (), how you would pass parameters ?
    I think it is better to keep them bracketed

    Regarding $ and #, this is interesting. For example in PowerBASIC, you can use this both ways to create single precision variable:
    [code=thinbasic]
    LOCAL floatie AS SINGLE
    ' or just
    LOCAL floatie!
    [/code]

    When I started working in it many years ago, I used the second type a lot. But as the time was passing, I "converted" to the first way. I don't know why...

    In current version of thinBASIC, you can use variable syntax you proposed already.
    So it is again just matter of personal preferences


    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    61
    Posts
    3,869
    Rep Power
    397

    Re: Coding Style Ideas

    It will be neat to see differnt ideas, I never thought about single precision and longs etc.

    About the subs with no (), I always think of subs as no parameters, just code you go to a lot.
    When I think Parameters I think in terms of Functions and the function can or doesn't have to return a value.

    The main thing is to come up with something that is uniform and help ease the ability to follow the code.
    I think it is nice that thinBasic is so flexible in allowing this sort of freedom of choice.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. CMCC11 - Coding Monkeys Coding Contest 2011
    By Cameron in forum Events
    Replies: 0
    Last Post: 22-01-2010, 13:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •