Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

zlua-default-arguments

/zlua-default-arguments

Pomija w Lua opcjonalne parametry C# na końcu i uzupełnia je buforowanymi wartościami domyślnymi.

Repozytorium
unity-mcp ↗
Licencja
MIT
Ostatnia zmiana repozytorium
02.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 02.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pomija w Lua opcjonalne parametry C# na końcu i uzupełnia je buforowanymi wartościami domyślnymi.

Oryginalny opis (EN)

Omits trailing C# optional parameters from Lua and fills them from the cached default values. Use when a method or constructor has parameters with default values, when Lua passes fewer arguments than the C# signature, or when an overload is chosen because it uses fewer defaults.

Jak działa

  1. Overloads
Sekcje z nagłówków SKILL.md, w oryginale · 48 linii, 315 słów
Podgląd SKILL.md
---
name: zlua-default-arguments
description: >-
  Omits trailing C# optional parameters from Lua and fills them from the
  cached default values. Use when a method or constructor has parameters with
  default values, when Lua passes fewer arguments than the C# signature, or
  when an overload is chosen because it uses fewer defaults.
---

# Default arguments

A C# method or constructor may omit a trailing run of parameters that have CLR `HasDefault`. Invoke writes the values cached at bind. The hot path does not read the metadata blob again.

```csharp
public static int Foo(int x, int y = 5) => x + y;
public static string Bar(string s, int a = 1, int b = 2) => $"{s}:{a},{b}";
```

```lua
Demo.Foo(1)          -- 6; y is 5
Demo.Foo(1, 9)       -- 10
Demo.Bar("hi")       -- "hi:1,2"
Demo.Bar("hi", 7)    -- "hi:7,2"
```

| Rule | Detail |
|------|--------|
| Trailing only | Same as C#. `void M(int x = 1, int y)` is not valid C#, and Lua cannot skip a required parameter in the middle |
| Arity | `minLuaArity ≤ argCount ≤ luaArity`. `minLuaArity` is the full Lua slot count minus the slots of the omitted tail |
| Too few | If the call does not cover the first parameter without a default, there is no match (`argument mismatch` or no overload) |
| `out` | An `out` parameter already takes 0 Lua slots. It is not a default argument. See `zlua-in-ref-out` |
| Constructors | `Type(...)` uses the same rule |

```lua
local p = Point(1)     -- Point(int x, int y = 0)
local q = Point()      -- only if every parameter has a default
```

`Type._default()` is zero-initialization of a struct. It does not call a constructor and does not apply parameter defaults.

## Overloads

When conversion scores tie, the candidate that uses fewer default arguments wins.

```csharp
public static int G(int x) => x;
public static int G(int x, int y = 5) => x + y;
```

```lua
Demo.G(1)      -- G(int); optionalUsed is 0
Demo.G(1, 4)   -- G(int, int)
```

Further ties, after that count: a whole `T[]` userdata beats `params` expansion, then a candidate without `params` beats one with `params`. See `zlua-params` and `zlua-method-overload`.

Wersje

W bazie nie ma innych skilli o nazwie zlua-default-arguments.

Migawka bazy z 13.11.2026 · wersja paczki 43085abdcda4 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 85zlua-method-overload
    Rozstrzyga przeciążenia metod C# z Lua: domyślny dobór, klucze pełnej sygnatury i moment użycia LuaAlias.
  • 95zlua-in-ref-out
    Przekazuje parametry ref, in i out z C# do Lua, zwracając wiele wyników z parametrów out.
  • 90lua-guide
    Pomaga pisać ogólne skrypty Lua 5.4+: moduły, zakresy zmiennych, metatabele, korutyny i obsługę błędów w plikach .lua.
  • 85Lua C Integration
    Omawia Lua C API do rozszerzania Lua kodem natywnym: operacje na stosie, wywołania C z Lua i odwrotnie, moduły C, userdata, metatabele i optymalizacje wydajności.
  • 100docs-search
    Wyszukuje funkcję, klasę lub API w wygenerowanej dokumentacji bazy kodu: sygnaturę, argumenty, parametry, typ zwracany i sposób użycia.
  • 100lua-embedding-scripting
    Osadza środowisko Lua w aplikacjach w C, Go i Rust, żeby obsługiwać skrypty pluginów i reguły konfiguracji.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.