Back to all reviewers

Use strongly typed configurations

ggml-org/llama.cpp
Based on 2 comments
C++

Prefer strongly typed configuration values over primitive types to improve code safety and clarity. Use enum classes instead of raw strings for categorical options, and proper boolean types instead of integer flags for binary settings.

Configurations C++

Reviewer Prompt

Prefer strongly typed configuration values over primitive types to improve code safety and clarity. Use enum classes instead of raw strings for categorical options, and proper boolean types instead of integer flags for binary settings.

For categorical configurations, replace string parameters with enum classes:

// Instead of:
params.dataset_format = format; // string

// Use:
enum class DatasetFormat { AUTO, TEXT, PARQUET, GGUF };
params.dataset_format = DatasetFormat::AUTO;

For boolean configurations, use explicit boolean conversion and values:

// Instead of:
supports_set_rows = LLAMA_SET_ROWS ? atoi(LLAMA_SET_ROWS) : 0;

// Use:
supports_set_rows = LLAMA_SET_ROWS ? atoi(LLAMA_SET_ROWS) != 0 : false;

This approach prevents invalid configuration values, makes code more self-documenting, and enables better IDE support with auto-completion and type checking.

2
Comments Analyzed
C++
Primary Language
Configurations
Category

Source Discussions