Confusion over compiler errors

14 views
Skip to first unread message

Daniel

unread,
Nov 5, 2016, 1:35:45 PM11/5/16
to Extempore
Hi all,

I'm a bit confused about compiler errors that I'm receiving for the following code (errors in red)
(bind-type Deque <QNode*,QNode*>)

(bind-func deque:[Deque{!a}*,!a]*
  (lambda (value)
    (let ((node (QNode value null null)))
      (Deque node node))))

(bind-func head:[QNode{!a}*,Deque{!a}]*
  (lambda (deque)
    (tref deque 0)))

(bind-func tail:[QNode{!a}*,Deque{!a}*]*
  (lambda (deque)
    (tref deque 1)))

($
 (let ((d (deque 1)))
   (println (null? (tref d 1))) ; => 0
   (println (null? (tail d))))) ; => Compiler Error  null must take a pointer type ast: (null? (head##597 d))

(bind-func emptyp:[i1,Deque*]*
  (lambda (deque)
    (if (and (null? (tref deque 0))
	     (null? (tref deque 1)))
	#t
	#f)))

;; fails with:
;; Could not resolve types!::xtlang_expression
;; ------------------------
;; 
($
 (let ((d:Deque{i64}* (Deque null null)))
   (if (emptyp d)
       "hi"
       "no")))

I'm sure that I'm misunderstanding something. It seems odd to me that (tref d 1) is not equivalent to (tail d) here, at the very least...

Also, the following closure compiles just fine:

(bind-func empty?:[i1,Deque*]*
  (lambda (deque)
    (if (and (null? (tref deque 0))
	     (null? (tref deque 1)))
	#t
	#f)))

but the compiler shouts when I try to compile the following:

($
 (let ((d:Deque{i64}* (Deque null null)))
   (if (empty? d)
       "hi"
       "no")))

**** DECL ****
**** ENDDECL ****

LLVM IR: <string>:59:34: error: expected '(' in function argument list
define dllexport fastcc i8 @empty?_poly_W2k4LERlcXVle2k2NH0qXSo__4654(i8* %_impz,i8* %_impenv, %Deque_poly_PGk2ND4* %deque_s_59) nounwind {
                                 ^

Compiler Error  compiler failed

best,

Danny

Andrew Sorensen

unread,
Nov 5, 2016, 3:53:21 PM11/5/16
to extemp...@googlegroups.com, Daniel
Hi Danny,

No question marks allowed in xtlang names :(

Only valid 'C language' names. Basically [A-Za-z][A-Za-z0-9_-]*

Cheers
Andrew.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Andrew Sorensen

unread,
Nov 5, 2016, 3:57:58 PM11/5/16
to extemp...@googlegroups.com, Daniel
I would like to move away from C lang naming (and ASCII) limitations in the future. However that's a more long term goal.

For now, could you add a github issue (with a simple example) addressing the need for a more friendly compiler error :)

Cheers
Andrew.

On 6 November 2016 3:35:43 am AEST, Daniel <hark...@gmail.com> wrote:

Andrew Sorensen

unread,
Nov 5, 2016, 4:10:23 PM11/5/16
to extemp...@googlegroups.com
Hi Danny,

Sorry, missed the first error in your message on first parse ;)

Your example works fine for me (no compiler error and both return 0).  Can you also send me your definition of QNode though just to confirm.  Also, are you running from head, or from the release binary?

Cheers,
Andrew. 

--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelang+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel

unread,
Nov 5, 2016, 4:35:47 PM11/5/16
to extemp...@googlegroups.com

Hi Andrew,

Here's QNode:

(bind-type QNode <!a,QNode*,QNode*>)

I believe I'm running from head: I "git pull"d and built from source.

Best,

Danny

-- You received this message because you are subscribed to the Google Groups "Extempore" group. To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Andrew Sorensen

unread,
Nov 5, 2016, 6:08:19 PM11/5/16
to extemp...@googlegroups.com
OK, that's what I guessed.  So your code is working fine for me (using emptp that is).  Everything compiles, and runs, as expected.

When you originally checked out extempore did you checkout from head, or from a release point? 

Daniel

unread,
Nov 5, 2016, 6:49:17 PM11/5/16
to extemp...@googlegroups.com

probably from head, though my memory of it isn't sharp.

-- You received this message because you are subscribed to the Google Groups "Extempore" group. To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Andrew Sorensen

unread,
Nov 5, 2016, 7:14:08 PM11/5/16
to extemp...@googlegroups.com
Ok, strange.  So just to be clear, if you restart Extempore and then run this code ...

 (bind-type QNode <!a,QNode*,QNode*>)
(bind-type Deque <QNode*,QNode*>)

(bind-func deque:[Deque{!a}*,!a]*
  (lambda (value)
    (let ((node (QNode value null null)))
      (Deque node node))))

(bind-func head:[QNode{!a}*,Deque{!a}]*
  (lambda (deque)
    (tref deque 0)))

(bind-func tail:[QNode{!a}*,Deque{!a}*]*
  (lambda (deque)
    (tref deque 1)))


(bind-func emptyp:[i1,Deque*]*
  (lambda (deque)
    (if (and (null? (tref deque 0))
             (null? (tref deque 1)))
        #t
        #f)))

;; test 1
($
 (let ((d (deque 1)))
   (println (null? (tref d 1))
            (null? (tail d)))))

;; test 2
($ (println
    (let ((d:Deque{i64}* (Deque null null)))
      (if (emptyp d)
          (Str "hi")
          (Str "no")))))




You *don't* get the following printed to the log?



Channels Out   : 2
Channels In    : 0
Frames         : 128
Latency        : 0.015034 sec
---------------------------------------

Starting utility process
Trying to connect to 'localhost' on port 7098
New Client Connection
Successfully connected to remote process

Starting primary process
Trying to connect to 'localhost' on port 7099
New Client Connection
Successfully connected to remote process
Loading xtmbase library... New Client Connection
done in 3.006984 seconds
GenrType:  QNode >>> <!a,QNode*,QNode*>
GenrType:  Deque >>> <QNode*,QNode*>
GenrFunc:  deque >>> [Deque{!a}*,!a]*
GenrFunc:  head >>> [QNode{!a}*,Deque{!a}]*
GenrFunc:  tail >>> [QNode{!a}*,Deque{!a}*]*
GenrFunc:  emptyp >>> [i1,Deque*]*
0 0
'hi'


Reply all
Reply to author
Forward
0 new messages