• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Scheme vs Common Lisp style in SKILL++

Stats

  • Locked Locked
  • Replies 18
  • Subscribers 144
  • Views 22564
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scheme vs Common Lisp style in SKILL++

tweeks
tweeks over 11 years ago

 While you can write your SKILL++ code like it is C, Maclisp, Scheme, or Common Lisp (or none of the above...), I've been experimenting with Common Lisp style lately.

Trying to write Common Lisp style code in SKILL++ can lead to curious situations like this:

(defvar first car)

The intention is to define FIRST as another name for CAR, as in Common Lisp.  In Scheme, we would write

(define first car)

which seems pretty natural, but using DEFVAR to define a function just feels.... wrong... somehow... :)

I guess I should use ALIAS:

 (alias second cadr)

 except ALIAS has weird limitations:

ILS-> (foo = first)
primop:car
ILS-> (foo '(1 2 3))
1
ILS-> (foo = second)
macro:evalalias
ILS-> (foo '(1 2 3))
*Error* evalalias: unknown alias - foo

  • Cancel
Parents
  • tweeks
    tweeks over 10 years ago

    Andrew Beckett said:

    Aliases are different again - they are a very old mechanism in SKILL to alias two functions. They predate SKILL++ (or ils mode) by some considerable time, and they are not intended to be copied by assignment. In fact all aliases share the same definition - they are all calling the evalalias macro, which actually looks for the alias property on the symbol to find out what it is aliased to. So they are not "weird", but you are assuming that they can be assigned, which is not the case.

    So you'd have to do:

    foo=second
    foo.alias=second.alias

    And then it would work. However, this is an undocumented implementation detail which you should not rely upon (in case it changes in future).

    Thanks Andrew.  It sounds like aliases are basically depricated now.

    Someone should make a list somewhere of all the stuff in SKILL that is deprecated--only kept for backwards-compatibility--and what the preferred contemporary equivalents are.

    Andrew Beckett said:

    Your mistake is that SKILL and SKILL++ are distinct dialects of LISP and are not either Scheme or Common Lisp or any of the others. They may share similar syntax to the other dialects, but they have different semantics.

    It's nice that SKILL tries to look syntactically familiar by borrowing from Scheme and Common Lisp.  However, because the semantics of SKILL/SKILL++ are, as you said, profoundly different from these languages, one occasionally runs into these jarring situations like in my OP where something that looks familiar is in fact is very different.  Imagine a programming language where you write "+" for multiplication.  Yes, "2 + 2 = 4", but "2 + 3 = 6".  You might wonder, "why use the plus sign if it isn't really addition?"

    SKILL provides a defun which looks like Common Lisp, but in SKILL++ mode it actually behaves like Scheme's define, because it binds the function lexically rather than globally.  This means that flet and labels are unnecessary in SKILL++, because you can simply nest defuns.  However, nesting defuns is extremely rare in Common Lisp, so it looks peculiar to do so in SKILL++, which I assume is why flet and labels were added in the first place!  It seems that it would be stylistically better to use define if you want to bind lexical functions by nesting, as Scheme programmers do.

    However, SKILL++ define is different from Scheme's because SKILL doesn't have dotted pairs / improper lists (which I think was a wise improvement, BTW), so to define an n-ary function you need to use the CL-style @rest keyword, which looks out of place in an otherwise elegant and minimal define (not to mention the argument type-template string!).  IEEE Scheme doesn't have keyword and optional arguments either (though some implementations add them as an extension).  The biggest problem with using define in SKILL++ is that SKILL++ code looks otherwise more like Common Lisp than Scheme: you write t and nil for true and false rather than separate boolean objects #t and #f; there's no "else" keyword for cond; defmacro is unhygienic (and define_syntax doesn't work right); tail-call optimization is unreliable in Virtuoso (though it seems to work fine in standalone SKILL); there are no first-class continuations; you can't use an exclamation point suffix to denote destructive functions (e.g. set!) without an ugly backslash; many core builtins are named in a Common Lisp style (or worse: C style!) rather than a Scheme style.....

    I'm really struggling with this issue of what is good style for SKILL/SKILL++.  I'd say, over all, SKILL/SKILL++ (considering them as one big language with two evaluation modes) feels more like a streamlined Common Lisp than an enhanced Scheme, because some of the "enhancements" would be viewed as regressive by Scheme programmers, while many Common Lisp programmers would probably say SKILL / SKILL++ is a nice simplification, streamlining many clunky aspects (one namespace for functions and variables rather than two), removing old warts (no more "improper lists"!), and adding some innovative improvements to make the language more user-friendly (the foreach, forall, setof, and exists macros are wonderful). 

    Since I've concluded SKILL/SKILL++ is best viewed as a refinement of Common Lisp, it seems like using a refined Common Lisp style is a sensible approach.  However, you do find yourself doing curious things, like using defvar to define a global function.  Maybe I should use define for this use-case?

    I still haven't decided whether it's better to use flet / labels or nested defuns....

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • tweeks
    tweeks over 10 years ago

    Andrew Beckett said:

    Aliases are different again - they are a very old mechanism in SKILL to alias two functions. They predate SKILL++ (or ils mode) by some considerable time, and they are not intended to be copied by assignment. In fact all aliases share the same definition - they are all calling the evalalias macro, which actually looks for the alias property on the symbol to find out what it is aliased to. So they are not "weird", but you are assuming that they can be assigned, which is not the case.

    So you'd have to do:

    foo=second
    foo.alias=second.alias

    And then it would work. However, this is an undocumented implementation detail which you should not rely upon (in case it changes in future).

    Thanks Andrew.  It sounds like aliases are basically depricated now.

    Someone should make a list somewhere of all the stuff in SKILL that is deprecated--only kept for backwards-compatibility--and what the preferred contemporary equivalents are.

    Andrew Beckett said:

    Your mistake is that SKILL and SKILL++ are distinct dialects of LISP and are not either Scheme or Common Lisp or any of the others. They may share similar syntax to the other dialects, but they have different semantics.

    It's nice that SKILL tries to look syntactically familiar by borrowing from Scheme and Common Lisp.  However, because the semantics of SKILL/SKILL++ are, as you said, profoundly different from these languages, one occasionally runs into these jarring situations like in my OP where something that looks familiar is in fact is very different.  Imagine a programming language where you write "+" for multiplication.  Yes, "2 + 2 = 4", but "2 + 3 = 6".  You might wonder, "why use the plus sign if it isn't really addition?"

    SKILL provides a defun which looks like Common Lisp, but in SKILL++ mode it actually behaves like Scheme's define, because it binds the function lexically rather than globally.  This means that flet and labels are unnecessary in SKILL++, because you can simply nest defuns.  However, nesting defuns is extremely rare in Common Lisp, so it looks peculiar to do so in SKILL++, which I assume is why flet and labels were added in the first place!  It seems that it would be stylistically better to use define if you want to bind lexical functions by nesting, as Scheme programmers do.

    However, SKILL++ define is different from Scheme's because SKILL doesn't have dotted pairs / improper lists (which I think was a wise improvement, BTW), so to define an n-ary function you need to use the CL-style @rest keyword, which looks out of place in an otherwise elegant and minimal define (not to mention the argument type-template string!).  IEEE Scheme doesn't have keyword and optional arguments either (though some implementations add them as an extension).  The biggest problem with using define in SKILL++ is that SKILL++ code looks otherwise more like Common Lisp than Scheme: you write t and nil for true and false rather than separate boolean objects #t and #f; there's no "else" keyword for cond; defmacro is unhygienic (and define_syntax doesn't work right); tail-call optimization is unreliable in Virtuoso (though it seems to work fine in standalone SKILL); there are no first-class continuations; you can't use an exclamation point suffix to denote destructive functions (e.g. set!) without an ugly backslash; many core builtins are named in a Common Lisp style (or worse: C style!) rather than a Scheme style.....

    I'm really struggling with this issue of what is good style for SKILL/SKILL++.  I'd say, over all, SKILL/SKILL++ (considering them as one big language with two evaluation modes) feels more like a streamlined Common Lisp than an enhanced Scheme, because some of the "enhancements" would be viewed as regressive by Scheme programmers, while many Common Lisp programmers would probably say SKILL / SKILL++ is a nice simplification, streamlining many clunky aspects (one namespace for functions and variables rather than two), removing old warts (no more "improper lists"!), and adding some innovative improvements to make the language more user-friendly (the foreach, forall, setof, and exists macros are wonderful). 

    Since I've concluded SKILL/SKILL++ is best viewed as a refinement of Common Lisp, it seems like using a refined Common Lisp style is a sensible approach.  However, you do find yourself doing curious things, like using defvar to define a global function.  Maybe I should use define for this use-case?

    I still haven't decided whether it's better to use flet / labels or nested defuns....

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information