Measures Concepts
GitHub icon

File Imports

File Imports - language feature

< >
Example from Java, Pizza, Oracle Java, Deesel:
import javax.swing.*; import javax.swing.JOptionPane; // use fully qualified name without import: javax.swing.JOptionPane.showMessageDialog(null, "Hi"); // There are 166 packages containing 3279 classes and interfaces in Java 5. // import java.io.*; Input-output classes.
Example from JavaScript:
import { helloWorld } from "./helloWorld.js";
Example from Python, Cython:
import datetime oTime = datetime.datetime.now() from my_pkg import my_funcs
Example from C, C++, Tick C:
// If a header file is included within <>, the preprocessor will search a predetermined directory path to locate the header file. If the header file is enclosed in "", the preprocessor will look for the header file in the same directory as the source file. #include <stdio.h> #include "stdio.h"
Example from PHP:
<?php include 'vars.php'; require 'filename'; // FATAL error if fails
Example from Perl:
use Digest::MD5 'md5_hex';
Example from Ruby:
load 'filename.rb' require 'filename' require 'trig.rb'
Example from MATLAB:
import pkg.cls1 import pkg.pkfcn
Example from C#:
using static System.Console; using static System.Math; class Program { static void Main() { WriteLine(Sqrt(3*3 + 4*4)); } }
Example from R:
source("filename.r")
Example from Go:
import ( "fmt" "math" ) import . "fmt" import _ "io" import log "github.com/foo/bar" import m "math"
Example from CSS:
@import 'custom.css';
Example from Swift:
import UIKit import UIKit.UITableViewController let tvc = UITableViewController() let vc = UIViewController() let label = UILabel()
Example from Rust:
use ::std::fs; // Imports from the `std` crate, not the module below. use self::std::fs as self_fs; // Imports the module below. mod my; use self::foo::Zoo as _; #[path = "foo.rs"] mod c;
Example from Kotlin:
import foo.Bar // Bar is now accessible without qualification import foo.* // everything in 'foo' becomes accessible import bar.Bar as bBar // bBar stands for 'bar.Bar'
Example from Haskell:
import Data.Maybe import Mod as Foo import Mod (x,y, (+++)) import qualified Mod import Mod hiding (x,y,(+++)) import qualified Mod hiding (x,y)
import { ZipCodeValidator } from "./ZipCodeValidator"; /// <reference path="../typings/jquery.d.ts"/> /// <reference path="components/someclass.ts"/> import moo = module('moo'); /// <amd-dependency path="legacy/moduleA" name="moduleA"/>
Example from Julia:
# Files and file names are mostly unrelated to modules; modules are associated only with module expressions. # One can have multiple files per module, and multiple modules per file: using MyModule using MyModule: x, p import MyModule import MyModule.x, MyModule.p import MyModule: x, p module Foo include("file1.jl") include("file2.jl") end
Example from Clojure:
(load "fun") (load "files/fun") (load-file "./files/fun.clj") (defproject project-a :dependencies [[org.clojure/clojure "1.5.1"] [project-b "0.1.0"]]) (require '[clojure.string :as string]) (use '[clojure.string :only [split]]) (import 'java.util.Date) (java.util.Date.) (require 'clojure.contrib.def 'clojure.contrib.except 'clojure.contrib.sql) (require '(clojure.contrib def except sql))
Example from Bash:
source ./bash.sh
Example from Node.js:
const jtree = require("jtree")
Example from Objective-C, cooC:
// #import ensures that a file is only ever included once so that you never have a problem with recursive includes. #import <Foundation/Foundation.h> #include <asl.h> #include <mach/mach.h>
Example from Elixir:
# Alias the module so it can be called as Bar instead of Foo.Bar alias Foo.Bar, as: Bar # Require the module in order to use its macros require Foo # Import functions from Foo so they can be called without the `Foo.` prefix import Foo # Invokes the custom code defined in Foo as an extension point use Foo
Example from Erlang:
-include("my_records.hrl"). -include("incdir/my_records.hrl"). -include("/home/user/proj/my_records.hrl"). -include("$PROJ_ROOT/my_records.hrl"). -include_lib("kernel/include/file.hrl").
Example from Dart:
import 'file-system.dart'; import 'dart:math' as math;
Example from Crystal:
require "../../spec_helper"
Example from F#:
open module-or-namespace-name open System.IO open List open Seq
Example from Racket:
(require (prefix-in tcp: racket/tcp))
Example from Pug:
//- index.pug doctype html html include includes/head.pug body h1 My Site p Welcome to my super lame site. include includes/foot.pug
Example from Ballerina:
import ballerina/http; import ballerina/io;
Example from X10:
import x10.io.Console;
Example from C3:
import std::io;
Example from Speedie:
import Proj
Example from Xtext:
import "http://www.xtext.org/example/Domainmodel" import "http://www.xtext.org/example/Domainmodel" as dmodel
Example from Slope:
(load-mod my-module) (load "examples/test.slo")
Example from Jule:
use std::fs use std::sys::{self, open, O_RDWR} use std::math::*
Example from Scroll:
import settings.scroll
Example from Flow9:
import runtime;
Example from bog:
let {print} = import "std.io"
Example from Cyber:
import m 'math'

Languages with File Imports include Java, JavaScript, Python, C, C++, PHP, Perl, Ruby, MATLAB, C#, R, Go, CSS, Swift, Rust, Kotlin, Haskell, TypeScript, Julia, Clojure, Bash, Node.js, Objective-C, Elixir, Erlang, Dart, Crystal, F#, Racket, Pug, Ballerina, X10, Cython, C3, Speedie, Xtext, progsbase, Slope, Jule, Pizza, Scroll, Flow9, Aardvark, bog, Cyber, Dale, Oracle Java, Deesel, Tick C, cooC, Static Typescript

Languages without File Imports include HTML, JSON, JSON5, Ion, JSONiq, JSON with Comments, Superjson, Jsonnet, Hocon

This question asks: Does this language have a syntax for importing other files?

HTML of this page generated by Features.ts

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Day 605 feedback@pldb.io Logout