stan-dev / stan-dev/stanc3

Chained comparison

Open
#823 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature good first issue
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

What does this Stan code do?

if (x < y < z) {

The natural (naïve?) reading is that the condition asks if x < y and y < z and that is indeed how Python or Julia would interpret it. (R considers it a syntax error.)
But Stan follows C/C++ convention where it reads (x < y) < z which is either 1 < z or 0 < z depending on whether or not x is less than y.

I think this should at least raise warning but preferably Stan could just implement comparison operators the same way Python and Julia do.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating how the Stan parser and compiler handle chained comparison expressions. Determine whether the project should warn about C-style evaluation or implement chained comparisons, then add coverage that demonstrates the chosen behavior and confirms the warning or semantics.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.