Temptory

Temptory

  • Install
  • Docs
  • Help

›IO

Temptory

  • Introduction

Verbs

  • Verbs for Batch-Processing
  • Verbs in Action

Verbs [Linear]

  • Verbs for Linear Batch-Processing

CodeBook

  • Hello, World!
  • ReadFromSTDIN
  • ReadFromSTDIN (2)
  • Longest Line
  • Counting Words
  • Counting Words (2)

IO

  • Under Construction

Under Construction

Say hello with user input...

#include "share/HATS/temptory_staload_bucs320.hats"

#define :: stream_vt_cons
#define nil stream_vt_nil


extern fun{} readio : () -> void
extern fun{} readio$err : () -> string
extern fun{} readio$foreach : string -> void

impltmp{} readio() =
  case+ !(FILEref_streamize_line(the_stdin<>())) of
    | ~nil() => println!(readio$err<>())
    | ~x::xs => (readio$foreach(x); free(xs))

implfun main0() = readio<>() where
{
  impltmp readio$err<>() = "Oops! No input"
  impltmp readio$foreach<>(x) = println!("Hello there ", x, "!")
}

How to Compile you might ask?

tempacc -DATS_MEMALLOC_LIBC -o hello hello.dats

Food for thought

Who owns memory management in ATS?

Let's break that down...

Includes

Here we include a hats file which exposes various modules that we can use.

#include "share/HATS/temptory_staload_bucs320.hats"

For ease

#define functions similarly to the C keyword. Here it is used just to make the code look nicer :)

#define nil stream_vt_nil

Now for the interesting part...

What does all this mean!?!

extern fun{} readio : () -> void
extern fun{} readio$err : () -> string
extern fun{} readio$foreach : string -> void
← Counting Words (2)
  • Say hello with user input...
  • How to Compile you might ask?
  • Food for thought
  • Let's break that down...
    • Includes
    • For ease
    • Now for the interesting part...
Copyright © 2019 sparverius