Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L ldpl
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lartu
  • ldpl
  • Merge requests
  • !62

Closed
Created Apr 22, 2019 by Lartu@lartu🐕Maintainer
  • Report abuse
Report abuse

Experiment: Internal sub procedures

  • Overview 4
  • Commits 4
  • Changes 2

Created by: dvkt

I have been thinking about this for a while and am not sure if there's any point, but seeing 25ed0ab5 made me think of it again.

This branch allows you to define LDPL sub-procedures in C++ from within LDPL. It's similar to STORE QUOTE where it just dumps everything you give it into the compiled code, except it looks for {$varname} or {$subname}() and replaces them with LDPL variables for convenience.

I'm not sure it's worth making the compiler more complicated but I needed to see this working to satisfy my curiosity. :^ ) If this isn't a fit we don't have to add it. It's probably easier to just write a .cpp file and include it directly with -i=.

Here's what it looks like:

DATA:
x is number
y is number
sum is number

PROCEDURE:
internal sub-procedure fast-add 
    {$sum} = {$x} + {$y};
end sub-procedure

display "X value: "
accept x 

display "Y value: "
accept y

call sub-procedure fast-add

display "Sum is " sum crlf

Or like this:

DATA:
name is text

PROCEDURE:
sub-procedure prompt
    display "Enter your name: "
    accept name
end sub-procedure

internal sub-procedure greet
    if({$name}.empty()){
        {$prompt}();
    }
    cout << "Hi there, " << {$name} << "!!" << endl;
end sub-procedure

call sub-procedure greet
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: github/fork/dvkt/internal-sub-procedures