Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6686989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:14:08+00:00 2026-05-26T05:14:08+00:00

Factor appears to have a main method like any C-based language: #! /usr/bin/env factor

  • 0

Factor appears to have a main method like any C-based language:

#! /usr/bin/env factor -script

USE: io
IN: hello

: hello ( -- ) "Hello World!" print ;

MAIN: hello

But Factor does not execute the main function automatically; if you run ./hello.factor in a terminal, nothing happens because main isn’t called.

Does anyone know if Factor has syntax like Python, so that hello is actually called on ./hello.py?

def hello():
   print "Hello World!"

if __name__=="__main__":
   main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:14:09+00:00Added an answer on May 26, 2026 at 5:14 am

    Factor will now execute a main function if one is specified. You’ll still have to edit ~/.factor-rc to add the INCLUDING/IN macros so that Factor will search for code in the current directory.

    ~/.factor-rc:

    ! Andrew Pennebaker
    ! INCLUDING macro that imports source code files in the current directory
    
    USING: kernel vocabs.loader parser sequences lexer vocabs.parser ;
    IN: syntax
    
    : include-vocab ( vocab -- ) dup ".factor" append parse-file append use-vocab ;
    
    SYNTAX: INCLUDING: ";" [ include-vocab ] each-token ;
    

    scriptedmain.factor:

    #! /usr/bin/env factor
    
    USING: io math.parser ;
    IN: scriptedmain
    
    : meaning-of-life ( -- n ) 42 ;
    
    : main ( -- ) meaning-of-life "Main: The meaning of life is " write number>string print ;
    
    MAIN: main
    

    test.factor:

    #! /usr/bin/env factor
    
    INCLUDING: scriptedmain ;
    USING: io math.parser ;
    IN: test
    
    : main ( -- ) meaning-of-life "Test: The meaning of life is " write number>string print ;
    
    MAIN: main
    

    Example:

    $ ./scriptedmain.factor
    Main: The meaning of life is 42
    $ ./test.factor
    Test: The meaning of life is 42

    As posted on RosettaCode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you plan on using Factor ? Have you looked at it? Checked it
Ease of installation/use is the most important factor here - not performance. Small is
I have data frame with some numerical variables and some categorical factor variables. The
We have to rename persistence.xml to fool WebSphere 7 not to use its built-in
I have recently been messing around with SFML , a multimedia library. I use
Suppose I have a factory method, which wants to construct an instance of a
Why are pointers such a leading factor of confusion for many new, and even
How do you specify the Fill Factor when creating an index in MySql?
Does anyone know what the q factor HTTP headers emitted by Firefox 3 mean?
From the online bar chart guide : qplot(factor(cyl), data=mtcars, geom=bar, fill=factor(gear)) How do I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.