google / google/xls

More ergonomic array_slice

Open
#2,433 0 comments 0 reactions 0 assignees View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

[`array_slice`](https://google.github.io/xls/dslx_std/#array_slice) takes a `want` arg that needs to be a value but is not actually used outside its type.

This just hinders readability IMO since how you populate that array value is irrelevant.

### Current best alternative workaround (limit 100 words)

Use it as is. For example, to write an array push/pop might look something like:

`array_slice(state, u32:1, zero!()) ++ foo_t[1]:[new_val]`

### Your view of the "best case XLS enhancement" (limit 100 words)

The docs say:

> . (Prior to constexprs being passed to built-in functions, this was the canonical way to reflect a constexpr in the type system.)

so not sure if this is just a vestige of early DSLX design.

I think we'd be better off adopting [vslice](https://google.github.io/xls/dslx_std/#stdvslice) syntax and just provide start/end as parametrics.

The `array_slice` above would just become:

`array_slice(state)`

or similar (e.g. inclusive vs. exclusive end syntax).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.