We welcome contributions to the WHEN language! This document outlines how to contribute effectively.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/yourusername/when-lang.git cd when-lang - Create a branch for your feature:
git checkout -b feature/your-feature-name
-
Install in development mode:
pip install -e ".[dev]" -
Test the installation:
when --version when examples/clock.when
- Use the issue tracker with a clear description
- Include steps to reproduce
- Provide the WHEN code that causes the issue
- Mention your Python version and OS
- Describe the feature and its use case
- Explain how it fits with WHEN's philosophy
- Consider proposing the syntax if it's a language feature
- Lexer (
lexer.py) - New keywords, operators, syntax - Parser (
parser.py) - Grammar rules, AST nodes - Interpreter (
interpreter.py) - Runtime behavior, built-ins - AST (
ast_nodes.py) - New node types
- Examples (
examples/) - Show off language features - Documentation (
docs/) - Language reference, tutorials - README improvements
- CLI (
when.py) - Command-line interface improvements - Testing - Unit tests, integration tests
- Performance - Optimizations, benchmarks
- Follow PEP 8
- Use type hints where helpful
- Keep functions focused and small
- Add docstrings for public APIs
- Use clear, descriptive variable names
- Prefer
whenconditions over complex logic - Comment complex block interactions
- Follow the examples' style
# Brief description of what this example demonstrates
import math # If needed
# Variables with clear names
counter = 0
active = 1
# Functions for reusable logic
def calculate_something(x):
return x * 2
# Blocks with clear purposes
os setup():
print("Example: Description")
print("Purpose: What this shows")
de timer(5):
counter = counter + 1
print("Step", counter)
fo monitor():
when counter >= 3:
print("Halfway!")
# Clear main logic
main:
when active == 1:
setup()
timer.start()
monitor.start()
active = 0
when counter >= 5:
print("Example complete!")
timer.stop()
monitor.stop()
exit()
# Install test dependencies
pip install -e ".[dev]"
# Run tests (when we add them)
pytest
# Test specific examples
when examples/clock.when
when examples/traffic_light.when- Add test files to
tests/directory - Test both positive and negative cases
- Include edge cases and error conditions
- Test examples to ensure they work
When contributing language features, consider WHEN's core principles:
- Loop-Centric: Everything happens in implicit loops
- Reactive:
whenconditions drive execution - Explicit Lifecycle: Clear
.start()and.stop()control - Cooperative: No hidden threading complexity
- Pythonic: Leverage Python's ecosystem and familiarity
- New block types (like
parallel fo) - Built-in functions for common patterns
- Syntax sugar for WHEN idioms
- Better error messages
- Complex threading abstractions
- Non-cooperative concurrency
- Breaking the loop paradigm
- Unnecessary syntax complexity
-
Update documentation if you change language features
-
Add examples demonstrating new functionality
-
Test thoroughly with various WHEN programs
-
Write clear commit messages:
feat: add parallel blocks for true concurrency - Adds `parallel fo` and `parallel de` block types - Implements thread-safe execution - Updates parser and interpreter - Includes example: parallel_demo.when -
Open a pull request with:
- Clear description of changes
- Examples of new functionality
- Screenshots if it affects output
- Links to related issues
- Be respectful and constructive
- Help newcomers learn WHEN
- Share interesting programs you've written
- Discuss ideas before implementing major changes
- Credit others for inspiration and help
- Issues: Use GitHub Issues for bugs and features
- Discussions: Use GitHub Discussions for general questions
- Examples: Share cool WHEN programs in discussions
Thank you for contributing to WHEN! 🎉