明确结构体的构造函数 #10

Open
opened 2023-09-02 03:31:02 +00:00 by szTom · 0 comments
Collaborator

对于一个命名的结构体,例如

struct And<A, B>(p: A, q: B) {};

它其实有一个编译器生成的隐藏构造函数 A: Fn(<A, B>, <A, B>, And<A, B>),但是现在我们的代码里无法指明这个构造函数,必须要嵌套一层:

AndConstructor = Fn<A, B>(p: A, q: B) -> And<A, B> {
  return And<A, B>(p, q);
};

是否可以考虑由编译器直接生成 And::constructor 之类的函数完成这一点?

对于一个命名的结构体,例如 ``` struct And<A, B>(p: A, q: B) {}; ``` 它其实有一个编译器生成的隐藏构造函数 `A: Fn(<A, B>, <A, B>, And<A, B>)`,但是现在我们的代码里无法指明这个构造函数,必须要嵌套一层: ``` AndConstructor = Fn<A, B>(p: A, q: B) -> And<A, B> { return And<A, B>(p, q); }; ``` 是否可以考虑由编译器直接生成 `And::constructor` 之类的函数完成这一点?
szTom added the
enhancement
label 2023-09-02 03:31:02 +00:00
szTom added this to the 9月迭代计划 project 2023-09-02 03:31:07 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ez_lcw/acpa#10
No description provided.