{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupiter Ada kernel\n", "\n", "The kernel accepts an Ada program piece by piece. A piece could be:\n", "1. A sequence of [context clauses](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-10-1-2.html#S0253):" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "with Ada.Text_IO;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. A sequence of [declarative items](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-3-11.html#S0087) to be elaborated:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "Name : constant String := \"World\";" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. A sequence of [statements](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-5-1.html#S0146) to be executed:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Hello World\n" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Ada.Text_IO.Put_Line (\"Hello \" & Name);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note: If one of declarative item requires a completion, then it should be in the same cell:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "package P is\n", " procedure Proc;\n", "end;\n", "\n", "package body P is\n", " procedure Proc is\n", " begin\n", " Ada.Text_IO.Put_Line (\"Here is Proc!\");\n", " end;\n", "end;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are also some \"magic\" commands:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Available line magics:\n", "%lsmagic? %alr? %%output? %%writefile? %gargs? %cargs? %largs? %bargs?" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%lsmagic" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use `%alr` magic command to install dependencies from the\n", "[Ada Library Repository](https://alire.ada.dev/). Only shared library\n", "projects are supported." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Do you want to proceed?\n", "Using default: Yes\n" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" }, { "data": { "text/plain": [ "Do you want Alire to automatically update your project file with the new dependency solution?\n", "Using default: Yes\n", "Do you want Alire to remember this choice?\n", "Using default: No\n" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%alr -q with spawn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After installing a crate with `%alr` you can use its units in `with` clauses:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "with Spawn.Environments;" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "TRUE\n" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Ada.Text_IO.Put_Line (Spawn.Environments.System_Environment.Contains (\"PATH\")'Image);" ] } ], "metadata": { "kernelspec": { "display_name": "Ada", "language": "ada", "name": "ada" }, "language_info": { "codemirror_mode": "ada", "file_extension": ".adb", "mimetype": "text/x-ada", "name": "Ada", "pygments_lexer": "ada", "version": "2012" } }, "nbformat": 4, "nbformat_minor": 4 }