Implement loading namespaces with the using keyword #829

Merged
ghallak merged 23 commits from ghallak/233 into master 2021-09-07 23:45:28 +09:00
ghallak commented 2021-08-24 00:38:16 +09:00 (Migrated from gitlab.com)

Fixes: #233
Fixes: #234

Fixes: #233 Fixes: #234
zxq9 commented 2021-08-24 18:29:06 +09:00 (Migrated from gitlab.com)

Created by: radrow

Review: Dismissed

Super!

*Created by: radrow* **Review:** Dismissed Super!
zxq9 commented 2021-08-24 18:39:25 +09:00 (Migrated from gitlab.com)

Created by: radrow

                                    lists:member(Name, Names)
*Created by: radrow* ```suggestion:-0+0 lists:member(Name, Names) ```
zxq9 commented 2021-08-24 18:39:49 +09:00 (Migrated from gitlab.com)

Created by: radrow

                                    not lists:member(Name, Names)
*Created by: radrow* ```suggestion:-0+0 not lists:member(Name, Names) ```
ghallak commented 2021-08-24 18:50:23 +09:00 (Migrated from gitlab.com)

I'm surprised that I wrote it this way. Will change.

I'm surprised that I wrote it this way. Will change.
zxq9 commented 2021-08-24 18:54:35 +09:00 (Migrated from gitlab.com)

Created by: radrow

No indefinite articles with plurals

Importing specific parts of a namespace or hiding these parts can also be
*Created by: radrow* No indefinite articles with plurals ```suggestion:-0+0 Importing specific parts of a namespace or hiding these parts can also be ```
zxq9 commented 2021-08-24 18:55:20 +09:00 (Migrated from gitlab.com)

Created by: radrow

Note that it is possible to use a namespace in the top level of the file, in the

In such documents it is better not to use abbreviated forms

*Created by: radrow* ```suggestion:-0+0 Note that it is possible to use a namespace in the top level of the file, in the ``` In such documents it is better not to use abbreviated forms
zxq9 commented 2021-08-24 18:55:48 +09:00 (Migrated from gitlab.com)

Created by: radrow

To avoid mentioning the namespace every time it is used, Sophia allows
*Created by: radrow* ```suggestion:-0+0 To avoid mentioning the namespace every time it is used, Sophia allows ```
zxq9 commented 2021-09-03 22:22:42 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Sorry I'm late to the party, but I was thinking about the example using_namespace_ambiguous_name - isn't the problem that you alias both Xa and Xb to A and the error is really on the line using Xb as A - the example reports two (other) errors? Otherwise it looks good to me.

Also there is a trivial conflict in documentation it seems.

*Created by: hanssv* Sorry I'm late to the party, but I was thinking about the example `using_namespace_ambiguous_name` - isn't the problem that you alias both `Xa` and `Xb` to `A` and the error is really on the line `using Xb as A` - the example reports two (other) errors? Otherwise it looks good to me. Also there is a trivial conflict in documentation it seems.
ghallak commented 2021-09-06 23:13:36 +09:00 (Migrated from gitlab.com)

isn't the problem that you alias both Xa and Xb to A and the error is really on the line using Xb as A - the example reports two (other) errors?

@hanssv I would say that it's not an error that two namespaces have the same alias, as these namespaces might have functions with different names:

namespace Xa = function f() = 1
namespace Xb = function g() = 2
contract Cntr =
  using Xa as A
  using Xb as A
  type state = int
  entrypoint init() = A.f() + A.g()

I think the above example should compile, and I can't think of a way that this could cause any bugs (beside that, haskell allows using the same alias for multiple modules).

> isn't the problem that you alias both `Xa` and `Xb` to `A` and the error is really on the line `using Xb as A` - the example reports two (other) errors? @hanssv I would say that it's not an error that two namespaces have the same alias, as these namespaces might have functions with different names: ``` namespace Xa = function f() = 1 namespace Xb = function g() = 2 contract Cntr = using Xa as A using Xb as A type state = int entrypoint init() = A.f() + A.g() ``` I think the above example should compile, and I can't think of a way that this could cause any bugs (beside that, haskell allows using the same alias for multiple modules).
zxq9 commented 2021-09-06 23:34:49 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Again, let me remind me about the target audience... Modeling things after Haskell might or might not be the correct thing 😅

That last example did not match my mental picture of things but I should be able to adapt the picture - possibly the documentation could clarify this?

*Created by: hanssv* Again, let me remind me about the target audience... Modeling things after Haskell might or might not be the correct thing 😅 That last example did not match my mental picture of things but I should be able to adapt the picture - possibly the documentation could clarify this?
ghallak commented 2021-09-06 23:54:55 +09:00 (Migrated from gitlab.com)

@hanssv I've updated the docs to here 7fabbff11e

@hanssv I've updated the docs to here 7fabbff11e07da8451df3d57a281f9bae7b3d739
zxq9 commented 2021-09-06 23:55:47 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Review: Approved

👍

*Created by: hanssv* **Review:** Approved 👍
zxq9 commented 2021-09-07 18:00:09 +09:00 (Migrated from gitlab.com)

Created by: radrow

Review: Approved

*Created by: radrow* **Review:** Approved
zxq9 commented 2021-09-07 23:45:28 +09:00 (Migrated from gitlab.com)

Merged by: ghallak at 2021-09-07 14:45:28 UTC

*Merged by: ghallak at 2021-09-07 14:45:28 UTC*
Sign in to join this conversation.
No description provided.