<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/language-feature/interfaces/interface-conjunction.slang, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2024-06-10T20:28:36+00:00</updated>
<entry>
<title>enable more metal tests (#4326)</title>
<updated>2024-06-10T20:28:36+00:00</updated>
<author>
<name>skallweitNV</name>
<email>64953474+skallweitNV@users.noreply.github.com</email>
</author>
<published>2024-06-10T20:28:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=712ce653d4c3d7284dd71389f31540d0da7f144e'/>
<id>urn:sha1:712ce653d4c3d7284dd71389f31540d0da7f144e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Metal compute tests (#4292)</title>
<updated>2024-06-07T07:28:16+00:00</updated>
<author>
<name>skallweitNV</name>
<email>64953474+skallweitNV@users.noreply.github.com</email>
</author>
<published>2024-06-07T07:28:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=004fe27a52b7952111ad7e749397aeff499de7ed'/>
<id>urn:sha1:004fe27a52b7952111ad7e749397aeff499de7ed</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Warning on lossy implicit casts. (#2367)</title>
<updated>2022-08-18T06:08:34+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-08-18T06:08:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=adaea0e993fd8db351b5dad92802e47ed6d0ec77'/>
<id>urn:sha1:adaea0e993fd8db351b5dad92802e47ed6d0ec77</id>
<content type='text'>
* Warning on bool to float conversion.

* Fix test cases.

* Improve.

* LanguageServer: don't show constant value for non constant variables.

* Fix tests.

* Fix warnings in tests.

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Initial implementation of interface conjunctions (#1691)</title>
<updated>2021-02-05T17:01:36+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-02-05T17:01:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=adb1131d08f28f0bc5f729e88b73cf22846c86c5'/>
<id>urn:sha1:adb1131d08f28f0bc5f729e88b73cf22846c86c5</id>
<content type='text'>
The basic feature here is the ability to use the `&amp;` operator to produce the conjunction/intersection of two interfaces. That is, you can have interfaces:

    interface IFirst { int getFirst(); }
    interface ISecond { int getSecoond(); }

and if you need a generic function where the type parameter `T` must conform to *both* of these interfaces, you express that by constraining the parameter to the intersection of the interfaces:

    void someFunction&lt;T : IFirst &amp; ISecond&gt;(T value) { ... }

Without this feature, the main alternative an application would have is to define an intermediate interface, like:

    interface IBoth : IFirst, ISecond {}

Forcing users to deal with an intermediate interface creates more work for type authors (they need to remember to inherit from the right combined interface(s)), or for `extension` authors (when you add `ISecond` to a type that used to just support `IFirst`, you had better also add `IBoth`). In the worst case, a family of N related "leaf" interfaces would give rise to an exponential number of intermediate interfaces to represnt the possible combinations.

A conjunction like `IFirst &amp; ISecond` is officially its own type, and can be used to declare a type alias:

    typealias IBoth = IFirst &amp; ISecond;

This change only includes the first pass of work on this feature, so there are several caveats to be aware of:

* Using a conjunction as part of an inheritance clause is not yet supported (e.g., `struct X : IFirst &amp; ISecond`). This is true even if the conjunction was introduced by an intermediate `typealias`

* The `&amp;` syntax introduced here is only parsed in places where only a type (not an expression) is possible. This means you cannot do things like cast to a conjunction with `(IFirst &amp; ISecond)(someValue)`.

* This work *should* apply to conjunctions of more than two interfaces (like `IA &amp; IB &amp; IC`) but that has not yet been tested

* In the long run it may be sensible to allow conjunctions that use concrete types, but we really ought to have the semantic checking logic rule that out for now.

* During testing, I encountered compiler crashes when trying to use this feature together with `property` declarations. Further investigation and debugging is called for.

* The handling of conjunction types is currently incomplete, in that there are many equivalences the compiler does not yet understand. For example, it is clear that `IA &amp; IB` is equivalent to `IB &amp; IA`, but the compiler currently does not understand this and will treat them as different types. A deeper implementation approach is called for.

* Conjunctions are currently only supported for generic type parameter constraints, when performing full specialization. Use of conjunctions for existential-type value parameters or with dynamic dispatch is not yet supported.</content>
</entry>
</feed>
