Sclang: The language client is inconsistent with its use of flushing the main post buffer

Open
#7,705 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
backend

Research direction

The issue names postChar and postText and describes flushing in the language client, but does not name source files or tests. Start by locating these functions and reading the compiler rewrite plan and language client code. Done means the rewrite uses separate normal and error streams and modern formatting as described; the issue says this work belongs with the compiler rewrite, so confirm that effort is underway before starting.

Written by the indexing model from the issue text.

Description

enhancement

Motivation

When you flush, you probably do a system call, you should avoid it until the end.

When printing characters, the language clients flushes after each...

void postChar(char c) {
    SC_LanguageClient* client = SC_LanguageClient::lockedInstance();
    if (client)
		// TODO: why is this flush? Surely if we are writing single characters this is the most inefficient way to do this?
        client->postFlush(&c, sizeof(char));
    SC_LanguageClient::unlockInstance();
}

When calling postText we also flush.


void postText(const char* str, std::size_t len) {
    SC_LanguageClient* client = SC_LanguageClient::lockedInstance();
    if (client){
		// TODO: why don't we call client->postText?
        client->postFlush(str, len);
	}
    SC_LanguageClient::unlockInstance();
}

Additionally it is assumed the error and normal post streams are the same and only one flush is provided.

These should be completely rewritten and real streams used. There is no need to expose a c interface for this, no one but us is writing their own language client, just use normal cpp streams for this.

We should also remove the nasty c var* functions and replace this with a modern format library (FMT). These will still be needed because unfortunately the class library uses the syntax 😒

Plan for Implementation

This should be done as part of the compiler rewrite, language clients needs a rethink when we do language servers anyway. Also, the language client should be able to decide where it prints errors and normal messages, therefore, we need separate streams ­— this should also be applied to the class library, so we might need some new printing functions here, or maybe a new class like Post, but ErrorPost.

Dominant language
C++
Stars
6.8k
Forks
854
Avg merge
2d 15h
Merged PRs (30d)
16

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from supercollider/supercollider

All issues in supercollider/supercollider

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.