Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main function is not generated #73

Closed
urosjarc opened this issue Sep 25, 2022 · 13 comments
Closed

Main function is not generated #73

urosjarc opened this issue Sep 25, 2022 · 13 comments
Assignees
Labels
enhancement New feature or request

Comments

@urosjarc
Copy link

urosjarc commented Sep 25, 2022

For the following languages, main function does not exists: c, cpp, python, js, ts.
For python the docs are correct.

SOURCE

public class MainP {

    public static void Main(string[] args)
    {
    }

}

c

// Generated automatically with "cito". Do not edit.
#include <stdlib.h>
#include "MainP.h"

struct MainP {
};

void MainP_Main(const char *const *args)
{
}

cpp

// Generated automatically with "cito". Do not edit.
#include "MainP.hpp"

void MainP::main(std::string_view const * args)
{
}

js

Expected result should be to call MainP.main function after definition.

// Generated automatically with "cito". Do not edit.

"use strict";

function MainP()
{
}

MainP.main = function(args)
{
}

python

Expected result should be

if __name__ == '__main__':
     MainP.main(sys.args)
# Generated automatically with "cito". Do not edit.

class MainP:

	@staticmethod
	def main(args):
		pass

ts

Expected result should be the same as with js.

// Generated automatically with "cito". Do not edit.
export class MainP
{
	public static main(args: readonly (string | null)[] | null): void
	{
	}
}

@urosjarc
Copy link
Author

BTW do you guys trying to target vanilla js or node.js?

@pfusik pfusik self-assigned this Sep 26, 2022
@pfusik
Copy link
Collaborator

pfusik commented Sep 26, 2022

This is by design. Unlike other programming languages, Ć is not meant for writing full programs, but only components/libraries easily usable from other programming languages. See some projects in Ć.

As for the other question, the goal is to target both. As of now there's just one built-in: Environment.GetEnvironmentVariable that only works with Node.js and not a browser.

@pfusik pfusik closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2022
@urosjarc
Copy link
Author

Cito to be recognized as an official language has to have a main function otherwise it's a joust library transpiler. Can you reopen this issue because I think it's an easy fix... check if the function signature matches the main function... Create some code in the output. Im considering to create pull request for this to fix it my self.

@pfusik
Copy link
Collaborator

pfusik commented Sep 26, 2022

Yes, it's a library transpiler. Why bother with transpiling if you compile to an exe in the end?

@urosjarc
Copy link
Author

I don't understand your logic on why this feature is not necessary. I would like to create complete programs with cito not joust libraries to be used somewhere else.

@pfusik
Copy link
Collaborator

pfusik commented Sep 26, 2022

I understand that you ask for is an ability to:

  1. Write a program in Ć.
  2. Transpile to e.g. C or C#.
  3. Compile the C or C# code into an executable.

I would rather write the whole program in C or C# instead. I don't see how Ć would add any value as a transpiler to whole programs?

@urosjarc
Copy link
Author

I still don't understand your logic... In cito source file... If user writes main function why wouldn't cito create main function in transpiled output? If user doesn't write main function then cito will not create main function... I don't see what is the problem here?

@pfusik
Copy link
Collaborator

pfusik commented Sep 26, 2022

Technically this should be rather easy. It could be very useful for people experimenting with Ć. I'll probably add it.

@pfusik pfusik reopened this Sep 26, 2022
@pfusik
Copy link
Collaborator

pfusik commented Sep 26, 2022

Also, it enables a simple testing system with no extra dependencies:

public static class Foo
{
    public static int Add(int x, int y) => x + y;
    public static void Main()
    {
        assert Add(1, 2) == 3;
        assert Add(5, 7) == 12;
    }
}

@ghost
Copy link

ghost commented Sep 27, 2023

Technically this should be rather easy. It could be very useful for people experimenting with Ć. I'll probably add it.

What do you want to do now? Should this issue be closed? You closed my issue!

@pfusik
Copy link
Collaborator

pfusik commented Sep 27, 2023

This is in queue. There are several tasks of higher priority.

@ghost
Copy link

ghost commented Sep 27, 2023

This is in queue. There are several tasks of higher priority.

Isn't the very trick you tell me could be used? So this is no longer a problem and you seem also not interested in finding a solution. As there is already workaround and adding support for Main function is a compromise on what Fusion was designed for in your opinion. Why don't you just close this as not planned the same way you closed my issue? The OP is gone. He said he will implement his own solution and he will not use Fusion (at that time still called Cito): #75 (reply in thread)

pfusik added a commit that referenced this issue Oct 31, 2023
pfusik added a commit that referenced this issue Oct 31, 2023
pfusik added a commit that referenced this issue Oct 31, 2023
pfusik added a commit that referenced this issue Oct 31, 2023
pfusik added a commit that referenced this issue Oct 31, 2023
pfusik added a commit that referenced this issue Nov 1, 2023
pfusik added a commit that referenced this issue Nov 1, 2023
pfusik added a commit that referenced this issue Nov 1, 2023
pfusik added a commit that referenced this issue Nov 1, 2023
pfusik added a commit that referenced this issue Nov 1, 2023
pfusik added a commit that referenced this issue Nov 2, 2023
pfusik added a commit that referenced this issue Nov 2, 2023
pfusik added a commit that referenced this issue Nov 2, 2023
@pfusik pfusik closed this as completed in 7c4a9b5 Nov 2, 2023
@pfusik
Copy link
Collaborator

pfusik commented Nov 2, 2023

This is implemented now. See the documentation.

pfusik added a commit that referenced this issue Nov 6, 2023
pfusik added a commit that referenced this issue Nov 6, 2023
pfusik added a commit that referenced this issue Nov 7, 2023
pfusik added a commit that referenced this issue Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants