trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
123 stars 43 forks source link

Simple python import #652

Closed astroseger closed 3 months ago

astroseger commented 3 months ago

Example of the implementation of simple but rather universal python import, which also adds support for keyword arguments for the call of python objects.

Few notes:

astroseger commented 3 months ago

@Necr0x0Der This PR does not implement simple "import", but in the full version it can be done. It seems there are two possibilities: I. (import numpy.linalg) adds operation atom "numpy", but it will require nice syntactic sugar for call python object with multiply dots (for example (numpy.linalg.inv m) ) , and also dealing with multiply imports, so "numpy" is added only once after importing both "numpy.linalg" and "numpy.fft"

II. Allowing to have operation atom with the name "numpy.linalg" (it seems it is forbidden in the current version).

Which solution is better will depend on will we make "multi dot" call of python objects easy.

  1. We need to implement syntax for "multi-dot" calls ("import" numpy.linalg)