News for hackers. Stuff that matters.
Re:Golang Is Good, Structure Is Bad by nerdponx on Sunday October 01, 2017 @09:45AM (#15377761)
FWIW this is a problem for Python as well:

    import requests

    # uh-oh!
    requests = []
    for url in ['http://google.com', 'http://duckduckgo.com']:
        with requests.get(url) as req:
            requests.append(req)
You'll get

    AttributeError: 'list' object has no attribute 'get'
because your sensibly-named `requests` object is shadowing the module. Obviously you could re-name it to `reqs` or something, but having module objects in a top-level global namespace can sometimes non-trivially increase cognitive load.

By comparison, R and Common Lisp have special syntax for accessing objects in namespaces. There are good and bad approaches to both. Having namespaces/packages exist alongside other objects makes it easier to reflect on their contents, obviating the need for specialized access functions.

There are no comments on this comment yet.