It seems like most of the style insensitivity issues are to do with FFI to case 
sensitive languages like C, where library developers have relied on case to 
distinguish variables, rather than problems developing in native Nim itself.

In regard to aliasing, I often find myself wanting a shorter name as a direct 
reference to something without a copy. A small wrapper for the template 
declaration makes things a bit nicer, if you don't need parameters.
    
    
    template alias(original, newName: untyped): untyped =
      template `newName`: auto = `original`
    
    # easier deep referencing
    type
      MyObj3 = object
        data: string
      MyObj2 = object
        obj3: MyObj3
      MyObj1 = object
        obj2: MyObj2
    
    var obj1: MyObj1
    
    alias obj1.obj2.obj3.data, data
    
    data = "Test"
    assert obj1.obj2.obj3.data == "Test"
    
    # replacing result
    import strutils, sequtils
    proc starredWords(curStr: string): string =
      alias result, words
      words = ""
      for s in curStr.split(' '):
        alias "*" & s.strip.capitalizeAscii & "* ", starredWord
        words &= starredWord
    
    var sw = starredWords("hello I like teapots")
    echo sw
    
    # only allow alias template in block scope
    template alias(original, newName, actions: untyped): untyped =
      block:
        template `newName`: auto = `original`
        actions
    
    var inputStr = "abc"
    alias inputStr.toUpperAscii, t:
      echo t  # t is only defined here
    

Reply via email to