> ## Documentation Index
> Fetch the complete documentation index at: https://sdk.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating from comptime_struct and @concat_structs

> How to migrate existing CSL code from comptime_struct and @concat_structs to named struct types.

<Note>
  The `comptime_struct` type and the `@concat_structs` builtin were removed in
  SDK 2.10.0. See [Version 2.10.0](/sdk-release-notes/sdk-rel-notes-cumulative#version-2100).
  This guide explains how to migrate existing code to use named `struct` types
  instead.
</Note>

For a full reference on struct types in CSL, see
[Types](/csl/language/types).

## Replacing `comptime_struct` with `struct`

As a consequence of the removal of `comptime_struct`, `@concat_structs` can no
longer be used.

**Before (removed):**

```csl theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
// Error: `comptime_struct` is no longer supported in CSL
const structA: comptime_struct;
const structB: comptime_struct;
const structC = @concat_structs(structA, structB);
```

**After:**

CSL now requires `struct` types to be declared explicitly. These can be used at
both compile time and runtime. The following code serves the equivalent
function to the above example:

```csl theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
const structA = struct {...};
const structB = struct {...};

const structC = struct {
   a: structA,
   b: structB,
};
```

## Partial Initialization

Another key difference between `comptime_struct` and `struct` is that all
fields must be declared and set. No partial initialization can be done,
sometimes requiring the use of temporary placeholders.

**Before (removed):**

```csl theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
var mystruct: comptime_struct = .{ .foo = true };
mystruct = @concat_structs(mystruct, .{ .bar = 42 });
```

**After:**

```csl theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
const mystruct_t = struct {
    foo: bool,
    bar: u16,
};
var mystruct: mystruct_t = .{
    .foo = true,
    .bar = 0, // Temporary placeholder value
};
mystruct.bar = 42;
```

## Parameterized Structs

Sometimes, the members of a given `struct` need to vary based on compile-time
parameters or constants. This can be achieved by writing a comptime function
that returns a `type`. The returned type is a `struct` whose fields depend on
the arguments passed to the function.

For example, a function that returns a point type whose coordinate type depends
on the scale type requested:

```csl theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
// Functions returning a type must have comptime arguments only.
fn point_type(comptime scalar_type: type) type {
    return struct {
        x: scalar_type,
        y: scalar_type,
    };
}

fn make_point(x_val: anytype) point_type(@type_of(x_val)) {
    return .{ .x = x_val, .y = 0 };
}
```

See also the [parameterized struct types example](/csl/language/types#parameterized-struct-types-example)
in the Language Guide for additional patterns.
