Skip to content

[Proposal] Allow writing code without OOP #171

@nxuv

Description

@nxuv

As title suggests, I think it'd be nice to be able to write code without using classes. It'd be nice for languages which don't strictly have to be encased in classes (basically all except Java and C#).

Then what to do with pure OOP languages?

Either throw a compiler error (easy way) or encase top level functions in class with filename as name (hard way).

Another possibility (combined with compile error if this pattern is missing):

// oop is defined when compiling to java or csharp
#if OOP
class Something {
#endif

// top level functions

#if OOP
}
#endif

Why?

Majority of languages don't strictly require everything to be inside of classes and class-based language promotes certain way of writing API and libraries (i.e builder pattern), being able to mix and match top level functions and classes would allow for greater freedom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions