Results 1 to 2 of 2

Thread: C-style #DEFINEs

Share/Bookmark

Threaded View

  1. #1

    C-style #DEFINEs

    Consider this code:
    Function HALQuote(myname as string) as string
    return "I'm sorry, "& myname &", I'm afraid I can't do that."
    end function
    
    When "HALQuote(*)" is evaluated, thinBasic has to bear the runtime costs of one function call, checking the argument's type, allocating two strings, and copying the argument's value twice. Compare that to the following:
    '#define HALQuote(myname) "I'm sorry, "& myname & ", I'm afraid I can't do that."
    
    When this "HALQuote(*)" appears in source code, thinBasic only needs to allocate one string and copy the argument's value once, without calling a function and without checking types. Although there will be some increased cost in preprocessing time or even runtime, depending on how this concept gets implemented in thinBasic. Also, macros like that must be used carefully, but I think this would be a nice option to have.
    Last edited by Vandalf; 06-03-2017 at 19:25. Reason: style

Similar Threads

  1. Tab control style
    By zlatkoAB in forum UI (User Interface)
    Replies: 1
    Last Post: 18-10-2013, 22:07
  2. MLGRID Style and ExStyle Options
    By RADRAD in forum UI (User Interface)
    Replies: 2
    Last Post: 14-05-2013, 20:55
  3. Dialog style updates
    By Michael Clease in forum Fixed or cleared errors in help material
    Replies: 1
    Last Post: 08-11-2007, 07:52
  4. Coding Style Ideas
    By kryton9 in forum thinBasic General
    Replies: 2
    Last Post: 13-12-2006, 21:49

Posting Permissions

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