trueagi-io / hyperon-experimental

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

current status of documentation #694

Closed DaddyWesker closed 3 months ago

DaddyWesker commented 6 months ago

Subj

get-doc/help! for empty doesn't work just like for =. For empty help! gives

Function empty (type (-> %Undefined%)) No documentation
[()]

For =:

Function = (type (-> $t#48 $t#48 Atom)) No documentation
[()]

Another problem is duplicating functions. There are several of them. I've tried to create some documentation which aggregate both variants but I wasn't been able to do it for every function. For example,@param. It uses two type notations. In the second one @param have two inputs but I don't get which ones. Same goes to @return.

Since currently documentation is duplicating for such functions even if there is only one documentation I'm currently commenting documentation for those funcs.

For some unknown to me reason, same problem doesn't occur for @doc-formal though it has two type notations as well.

help! also doesn't show anything for (@kind function) and (@kind atom).

DaddyWesker commented 5 months ago

@vsbogd There are two types of problems. First, for some reason get-doc/help for some reason returns "No documentation" for some functions. Second, for &self metta hangs for some time and then segmentation fault. I've tried to understand what is a reason behind this. For the second problem, segmentation fault could be triggered using such code:

!(let $top-space (mod-space! top)
    (unify $top-space (@doc &self $desc (@params $params) $ret)
        $ret
        Err))

So segmentation fault happening on this step. Unfortunately, I don't know why.

As for the first problem, it is somewhat tricky. For example, two functions: xor and or. Both have two input parameters and output. Here is docs:

(@doc or
  (@desc "Logical disjunction of two arguments")
  (@params (
    (@param "First argument")
    (@param "Second argument")))
  (@return "True if any of input arguments is True, False - otherwise"))

(@doc xor
  (@desc "Exclusive disjunction of two arguments")
  (@params (
    (@param "First argument")
    (@param "Second argument")))
  (@return "Return values are the same as logical disjunction, but when both arguments are True xor will return False"))

So, those docs are kinda similar, but !(help! xor) gives:

Function xor: (-> Bool Bool Bool) Exclusive disjunction of two arguments
Parameters:
  (type Bool) First argument
  (type Bool) Second argument
Return: (type Bool) Return values are the same as logical disjunction, but when both arguments are True xor will return False
[()]

and !(help! or) gives:

Function or (type (-> Bool Bool Bool)) No documentation
[()]

I don't get it. If I'll use this code once again

!(let $top-space (mod-space! top)
    (unify $top-space (@doc or $desc (@params $params) $ret)
        $ret
        Err))

I'll get Err. So for some reason unify doesn't work for or.

Moreover, if I'll add doc for or inside script I'm launching, everything will be fine. Unfortunately, I don't know inner structure of metta so I can't understand what is happening here.

vsbogd commented 5 months ago

@DaddyWesker could you please also add docs for operations added by #698 and here https://github.com/trueagi-io/hyperon-experimental/pull/691/files#diff-0cc50ef2951a3babcc599e443e489112ae31c6f8e76da2d22b97160ad85d9a32

DaddyWesker commented 5 months ago

@DaddyWesker could you please also add docs for operations added by #698 and here https://github.com/trueagi-io/hyperon-experimental/pull/691/files#diff-0cc50ef2951a3babcc599e443e489112ae31c6f8e76da2d22b97160ad85d9a32

Probably done. Please check.

vsbogd commented 3 months ago

@DaddyWesker please merge my review comments in https://github.com/DaddyWesker/hyperon-experimental/pull/3