{ "info": { "author": "Michael Williamson", "author_email": "mike@zwobble.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "The Nope Programming Language\n=============================\n\nNope is a statically-typed subset of Python 3 that can be compiled to multiple targets.\nAt the moment, only Python and node.js are supported.\nAny valid Nope program can be run directly as a Python 3 program.\n\nStatic typing is supported for two main reasons:\n\n* Static typing can detect some programming errors more quickly\n\n* Static typing allows optimisations to be applied to the generated code\n\nThe static types are expressed using comments, rather than annotations, for\nseveral reasons:\n\n* This means the static typing has no effect at runtime, allowing Nope programs\n to be run directly as Python 3 programs without any extra dependencies or\n performance penalty.\n\n* A separate syntax can be used within the comments to succinctly express types,\n rather than (ab)using existing Python syntax.\n\n* It can be useful to decouple the signature of a function from the implementation.\n For instance, using separate comments makes it easy to type a function such\n that it only accepts arguments by positions rather than keyword.\n\nHere's an example of calculating Fibonacci numbers using Nope:\n\n.. code-block:: python\n\n #:: int -> int\n def fib(n):\n seq = [0, 1]\n for i in range(2, n + 1):\n seq.append(seq[i - 1] + seq[i - 2])\n \n return seq[n]\n\n print(fib(10))\n\nTODO\n----\n\n* When defining `__add__` and similar methods on classes,\n the type signature should be specific e.g. on int, ``int -> int``.\n However, to maintain compatibility with Python,\n the type checker should assume the argument is the top type when type\n checking the actual method, so isinstance or similar still has to be used.\n\n* Support for the r versions of operators e.g. ``__radd__``.\n\n* Inheritance\n\n* ``__init__`` methods\n\n* Standard library support\n\n* A way of specifying dependencies on a per-platform basis to allow shimming\n of existing libraries into a common interface.\n\n* Allow types of variables to be specified in the same way as functions, such\n as giving the type of an empty list.\n\n* If a class definition body contains a value of type object that could\n be a function (but that is not possible to determine at runtime), how\n should it be treated? In Python, if it's a function, we bind it to the\n instance. Is it possible to sensibly do the same in other languages?\n The result is that any value of type object will need to be checked\n as to whether it is a function or not for consistency.\n\n* Proper tests for builtin functions\n\n* Prevent re-definition of functions and classes\n\n* Allow mutually recursive functions\n\n* Ensure that all signatures are used in typing rules\n\nStatus\n------\n\nSyntax\n~~~~~~\n\nThis section describes support for parsing and type-checking each of\n`Python 3.4's syntax nodes `_.\nNote that not all backends may support all features.\n\n* **Function definitions**: partially supported.\n\n * **name**: supported.\n \n * **arguments**: partially supported.\n Positional and keyword arguments are supported, but nothing else\n (default values, ``*args``, ``**kwargs``, keyword-only arguments).\n \n * **body**: supported.\n \n * **decorators**: unsupported.\n \n * **annotations**: unsupported (both argument and return annotations).\n \n The signature of a function should be specified by a signature comment immediately before the function definition.\n For instance:\n \n .. code-block:: python\n\n #:: int -> int\n def increment(x):\n return x + 1\n \n #:: int, str -> none\n def repeated_greeting(repeat, message):\n for i in range(0, repeat):\n print(message)\n \n #:: repeat: int, message: str -> none\n def repeated_greeting(repeat, message):\n for i in range(0, repeat):\n print(message)\n\n* **Class definitions**: unsupported.\n\n* **Return statements**: supported.\n\n* **Delete statements**: unsupported.\n\n* **Assignments**: partially supported.\n Assignments to variables (e.g. ``x``), elements of sequences (e.g. ``x[i]``), and attributes (e.g. ``x.y``)\n are supported, but not assignment to slices (e.g. ``x[:]``).\n\n* **Augmented assignments**: unsupported.\n\n* **For loops**: supported.\n \n* **While loops**: supported.\n\n* **If statements**: supported.\n\n* **With statements**: supported.\n\n* **Raise statements**: partially supported.\n Only statements in the form ``raise value`` are supported.\n ``raise``, ``raise ExceptionType`` and ``raise value1 from value2`` are unsupported.\n\n* **Try statements**: partially supported.\n Tuples of exceptions are not supported when specifying the type in exception handlers.\n The ``else`` branch is ignored.\n\n* **Assert statements**: supported.\n\n* **Import statements**: partially supported.\n The various forms of import statement are supported.\n However, only local modules are currently supported.\n Modules from the standard library or dependencies are unsupported.\n \n* **global keyword**: unsupported.\n\n* **nonlocal keyword**: unsupported.\n\n* **Expression statements**: supported.\n\n* **pass keyword**: supported.\n\n* **break keyword**: supported.\n\n* **continue keyword**: supported.\n\nWith statements\n~~~~~~~~~~~~~~~\n\nConsider the following:\n\n.. code-block:: python\n\n with x:\n y = f()\n \n g(y)\n\nIt isn't guaranteed that ``y`` has been assigned a value since ``f()`` could\nraise an exception that is then suppressed by the context manager's ``__exit__`` method.\nTherefore, ``g(y)`` fails to type-check.\n(If the exception isn't suppressed by the ``__exit__`` method, we can safely\nassume treat the variable as assigned since we won't be executing any code after the exception).\nHowever, in the common case, we'd like to be able to assume that the variable has been assigned,\nand such an assumption is safe in many cases, such as:\n\n.. code-block:: python\n\n with open(path) as file_:\n contents = file_.read()\n \n print(contents)\n\nWe can allow such examples to type-check by inspecting the type of ``__exit__``.\nIf its return type is ``none``, then it is guaranteed to return a false value,\nmeaning it will never suppress exceptions.\n\n\nPython\n~~~~~~\n\nAny valid Nope program should be directly executable using Python 3.4.\nThe best way to support earlier versions of Python is in the same way as you would\non a normal Python 3.4 codebase i.e. avoiding features unsupported in earlier versions.\n\nNode.js backend\n~~~~~~~~~~~~~~~\n\nSupported builtin functions:\n\n* ``abs``: supported\n\n* ``bool``: partially supported. The magic method ``__bool__`` is ignored.\n\n* ``iter``: partially supported. The sequence protocol is unsupported.\n\n* ``print``: only a single argument is accepted.\n\nUnimplemented optimisations:\n\n* If the result of boolean operations ('and' or 'or') is only used as a\n condition, such as the condition of an 'if' statement or 'while' loop,\n then the value can simply be true or false rather than the actual value\n of the operation. In other words, ``x and y`` can be optimised to\n ``bool(x) && bool(y)``.\n\n* Unless ``bool()`` has been explicitly invoked, booleans, strings and integers\n can be used directly if only used for their truth value e.g. in if statement\n conditions.\n\n* Avoid re-evaluating bool(value) if boolean operations are used directly in\n conditions. For instance, in ``if x and y``, ``bool(x)`` only needs to be\n evaluated once, even if ``bool(x)`` is ``True``. (A naive implementation\n evalutes ``bool(x)`` once for the ``and`` operation, which would have the\n value of ``x``, causing ``bool(x)`` to be evaluated again as the condition\n of the ``if`` statement.)\n\n\nDifferences from Python 3\n-------------------------\n\nSubclassing builtins\n~~~~~~~~~~~~~~~~~~~~~\n\nNope does not allow subclassing of some builtins,\nsuch as ``int`` and ``list``.\nThis restraint means a value of type ``int`` is guaranteed to have the concrete type ``int`` rather than a subclass of ``int``,\nallowing certain optimisations to be used when generating code.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mwilliamson/nope", "keywords": "nope static type", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "nope", "package_url": "https://pypi.org/project/nope/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/nope/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/mwilliamson/nope" }, "release_url": "https://pypi.org/project/nope/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Statically type a subset of Python 3", "version": "0.1.0" }, "last_serial": 1530325, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "4593c245d001145035a6b7587b14c0cf", "sha256": "f83ede236551581eaba4537d9be51d680459ed32873beb7bf34eee13c717176d" }, "downloads": -1, "filename": "nope-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4593c245d001145035a6b7587b14c0cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 65201, "upload_time": "2015-05-02T12:21:57", "url": "https://files.pythonhosted.org/packages/e9/9a/e69e8180d134565f67aefa2175bf71b3ec2a2acba4523dc7f11030a3d184/nope-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4593c245d001145035a6b7587b14c0cf", "sha256": "f83ede236551581eaba4537d9be51d680459ed32873beb7bf34eee13c717176d" }, "downloads": -1, "filename": "nope-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4593c245d001145035a6b7587b14c0cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 65201, "upload_time": "2015-05-02T12:21:57", "url": "https://files.pythonhosted.org/packages/e9/9a/e69e8180d134565f67aefa2175bf71b3ec2a2acba4523dc7f11030a3d184/nope-0.1.0.tar.gz" } ] }